This commit is contained in:
eric
2026-03-29 02:14:17 -05:00
parent c3ee09674f
commit 16dc9abbbb
8 changed files with 355 additions and 36 deletions

View File

@@ -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") {