's'
This commit is contained in:
@@ -259,22 +259,6 @@ export function LiveYoutubeUnmannedView({
|
||||
}
|
||||
}, []);
|
||||
|
||||
const setModePersist = (m: "single" | "pro") => {
|
||||
setMode(m);
|
||||
if (m === "pro") {
|
||||
const ch = channels.find((c) => c.id === activeCh) ?? channels[0];
|
||||
if (ch) {
|
||||
const u = (ch.urlLines ?? "").trim();
|
||||
setProUrlDraft(u || urlConfig);
|
||||
}
|
||||
}
|
||||
try {
|
||||
window.localStorage.setItem(MODE_KEY, m);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const list = loadYoutubeProChannels();
|
||||
const initial =
|
||||
@@ -308,6 +292,52 @@ export function LiveYoutubeUnmannedView({
|
||||
|
||||
const active = channels.find((c) => c.id === activeCh) || channels[0];
|
||||
|
||||
const setModePersist = useCallback(
|
||||
(m: "single" | "pro") => {
|
||||
if (m === "single" && mode === "pro" && active) {
|
||||
persistChannels(channels.map((x) => (x.id === active.id ? { ...x, urlLines: proUrlDraft } : x)));
|
||||
}
|
||||
if (m === "pro" && channels.length) {
|
||||
const first = channels[0];
|
||||
const youtubePm2Ok = ytEntries.some((e) => e.pm2 === currentProc);
|
||||
const pm2Name =
|
||||
youtubePm2Ok && currentProc.trim()
|
||||
? currentProc.trim()
|
||||
: (first.pm2Name ?? "").trim() || defaultPm2NameForChannel(first.id);
|
||||
const next: YoutubeProChannel[] = [
|
||||
{
|
||||
...first,
|
||||
streamKey: ytFields.key.trim() || first.streamKey || "",
|
||||
urlLines: urlConfig.trim() || first.urlLines || "",
|
||||
pm2Name,
|
||||
},
|
||||
...channels.slice(1),
|
||||
];
|
||||
persistChannels(next);
|
||||
const ch = next.find((c) => c.id === activeCh) ?? next[0];
|
||||
setProUrlDraft((ch?.urlLines ?? "").trim() || urlConfig.trim());
|
||||
}
|
||||
setMode(m);
|
||||
try {
|
||||
window.localStorage.setItem(MODE_KEY, m);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
},
|
||||
[
|
||||
mode,
|
||||
active,
|
||||
channels,
|
||||
proUrlDraft,
|
||||
ytFields.key,
|
||||
urlConfig,
|
||||
currentProc,
|
||||
ytEntries,
|
||||
activeCh,
|
||||
persistChannels,
|
||||
],
|
||||
);
|
||||
|
||||
const selectProChannel = useCallback(
|
||||
(c: YoutubeProChannel) => {
|
||||
if (active && mode === "pro") {
|
||||
|
||||
Reference in New Issue
Block a user