MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / reorderChannels

Function reorderChannels

apps/web/ui/ChannelsView/index.tsx:139–155  ·  view source on GitHub ↗
(
    channels: SerializedChannel[],
    from: string,
    to: string | null
  )

Source from the content-addressed store, hash-verified

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));

Callers 2

onDropFunction · 0.85
setUserChannelsFunction · 0.85

Calls 2

moveFunction · 0.90
mapMethod · 0.80

Tested by

no test coverage detected