MCPcopy Index your code
hub / github.com/Dispatcharr/Dispatcharr / reorderChannelStreams

Method reorderChannelStreams

frontend/src/api.js:718–740  ·  view source on GitHub ↗

* PATCHes only the stream order for a channel * without triggering requeryStreams or requeryChannels. The caller is * responsible for optimistic UI updates.

(channelId, streamIds)

Source from the content-addressed store, hash-verified

716 * responsible for optimistic UI updates.
717 */
718 static async reorderChannelStreams(channelId, streamIds) {
719 try {
720 await request(`${host}/api/channels/channels/${channelId}/`, {
721 method: 'PATCH',
722 body: { id: channelId, streams: streamIds },
723 });
724 // Update the channelsTable store in-place with the new stream order
725 const store = useChannelsTableStore.getState();
726 const channel = store.channels.find((c) => c.id === channelId);
727 if (channel) {
728 // Reorder the existing stream objects to match streamIds
729 const streamMap = new Map(channel.streams.map((s) => [s.id, s]));
730 const reorderedStreams = streamIds
731 .map((id) => streamMap.get(id))
732 .filter(Boolean);
733 store.updateChannel({ ...channel, streams: reorderedStreams });
734 }
735 } catch (e) {
736 errorNotification('Failed to reorder streams', e);
737 // On failure, requery to restore correct state
738 await API.requeryChannels();
739 }
740 }
741
742 /**
743 * PATCHes the channel with the

Callers 1

ChannelStreamsFunction · 0.80

Calls 6

requestFunction · 0.85
errorNotificationFunction · 0.85
updateChannelMethod · 0.80
requeryChannelsMethod · 0.80
filterMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected