feat(cmd-palette): add streamer search — type name or @login to jump
Reads config.streamers from the renderer global, builds one command per
streamer with label=name and keywords='@name name'. Action: showTab('vods')
+ selectStreamer(name). No-op if selectStreamer is unavailable
(e.g. on platforms where the streamers list wasn't loaded yet).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a6b64ddf15
commit
825c5dc96c
@ -18,27 +18,55 @@ interface PaletteCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function buildCommands(): PaletteCommand[] {
|
function buildCommands(): PaletteCommand[] {
|
||||||
const showTab = (window as unknown as { showTab?: (tab: string) => void }).showTab;
|
const w = window as unknown as {
|
||||||
|
showTab?: (tab: string) => void;
|
||||||
|
selectStreamer?: (name: string, forceRefresh?: boolean) => Promise<void>;
|
||||||
|
config?: { streamers?: Array<{ name: string }> };
|
||||||
|
};
|
||||||
|
const showTab = w.showTab;
|
||||||
if (typeof showTab !== 'function') {
|
if (typeof showTab !== 'function') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const tabs: Array<{ id: string; labels: string[]; hint: string }> = [
|
const tabs: Array<{ id: string; labels: string[]; hint: string }> = [
|
||||||
{ id: 'vods', labels: ['VODs', 'videos', 'streams'], hint: 'Go' },
|
{ id: 'vods', labels: ['VODs', 'videos', 'streams'], hint: 'Tab' },
|
||||||
{ id: 'queue', labels: ['Queue', 'downloads', 'warteschlange'], hint: 'Go' },
|
{ id: 'queue', labels: ['Queue', 'downloads', 'warteschlange'], hint: 'Tab' },
|
||||||
{ id: 'streamers', labels: ['Streamers', 'channels'], hint: 'Go' },
|
{ id: 'streamers', labels: ['Streamers', 'channels'], hint: 'Tab' },
|
||||||
{ id: 'stats', labels: ['Stats', 'statistiken', 'dashboard'], hint: 'Go' },
|
{ id: 'stats', labels: ['Stats', 'statistiken', 'dashboard'], hint: 'Tab' },
|
||||||
{ id: 'archive', labels: ['Archive', 'archiv'], hint: 'Go' },
|
{ id: 'archive', labels: ['Archive', 'archiv'], hint: 'Tab' },
|
||||||
{ id: 'settings', labels: ['Settings', 'einstellungen', 'config'], hint: 'Go' },
|
{ id: 'settings', labels: ['Settings', 'einstellungen', 'config'], hint: 'Tab' },
|
||||||
];
|
];
|
||||||
|
|
||||||
return tabs.map(t => ({
|
const tabCommands: PaletteCommand[] = tabs.map(t => ({
|
||||||
id: 'tab:' + t.id,
|
id: 'tab:' + t.id,
|
||||||
label: t.labels[0],
|
label: t.labels[0],
|
||||||
hint: t.hint,
|
hint: t.hint,
|
||||||
keywords: t.labels.join(' ').toLowerCase(),
|
keywords: t.labels.join(' ').toLowerCase(),
|
||||||
action: () => showTab(t.id),
|
action: () => showTab(t.id),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Streamer-Liste aus globalem config (gefuellt nach renderer-Init).
|
||||||
|
const streamerCommands: PaletteCommand[] = [];
|
||||||
|
const streamers = Array.isArray(w.config?.streamers) ? w.config.streamers : [];
|
||||||
|
const selectStreamer = w.selectStreamer;
|
||||||
|
if (typeof selectStreamer === 'function') {
|
||||||
|
for (const entry of streamers) {
|
||||||
|
if (!entry || typeof entry.name !== 'string') continue;
|
||||||
|
const name = entry.name;
|
||||||
|
streamerCommands.push({
|
||||||
|
id: 'streamer:' + name.toLowerCase(),
|
||||||
|
label: name,
|
||||||
|
hint: 'Streamer',
|
||||||
|
keywords: ('@' + name + ' ' + name).toLowerCase(),
|
||||||
|
action: () => {
|
||||||
|
showTab('vods');
|
||||||
|
void selectStreamer(name);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...tabCommands, ...streamerCommands];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getModal(): HTMLElement | null {
|
function getModal(): HTMLElement | null {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user