MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / sortedChannelOptions

Function sortedChannelOptions

frontend/src/utils/forms/RecordingUtils.js:67–85  ·  view source on GitHub ↗
(channels, labelFn)

Source from the content-addressed store, hash-verified

65 * @param {(item: object) => string} [labelFn] defaults to `name || "Channel id"`
66 */
67export const sortedChannelOptions = (channels, labelFn) => {
68 const list = Array.isArray(channels)
69 ? channels
70 : Object.values(channels || {});
71
72 const defaultLabel = (item) => item.name || `Channel ${item.id}`;
73
74 return [...list]
75 .sort((a, b) => {
76 const aNum = Number(a.channel_number) || 0;
77 const bNum = Number(b.channel_number) || 0;
78 if (aNum !== bNum) return aNum - bNum;
79 return (a.name || '').localeCompare(b.name || '');
80 })
81 .map((item) => ({
82 value: String(item.id),
83 label: (labelFn ?? defaultLabel)(item),
84 }));
85};
86
87/** Label that includes the channel number prefix used in Recording/SeriesRule UIs. */
88export const numberedChannelLabel = (item) =>

Callers 4

RecordingModalFunction · 0.90
RecurringRuleModalFunction · 0.90
getChannelOptionsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected