(
channels: SerializedChannel[],
from: string,
to: string | null
)
| 137 | }; |
| 138 | |
| 139 | function reorderChannels( |
| 140 | channels: SerializedChannel[], |
| 141 | from: string, |
| 142 | to: string | null |
| 143 | ): SerializedChannel[] { |
| 144 | const fromIndex = channels.findIndex((channel) => channel.id === from); |
| 145 | const toIndex = channels.findIndex((channel) => channel.id === to); |
| 146 | if (fromIndex >= 0 && toIndex >= 0) { |
| 147 | return move(channels, fromIndex, toIndex).map((channel, index) => { |
| 148 | return { |
| 149 | ...channel, |
| 150 | displayOrder: index, |
| 151 | }; |
| 152 | }); |
| 153 | } |
| 154 | return channels; |
| 155 | } |
| 156 | |
| 157 | function setUserChannels(from: string, to: string | null) { |
| 158 | setChannels(reorderChannels(channels, from, to)); |
no test coverage detected