diff --git a/src/renderer-command-palette.ts b/src/renderer-command-palette.ts index 75f1826..63e2dfe 100644 --- a/src/renderer-command-palette.ts +++ b/src/renderer-command-palette.ts @@ -18,27 +18,55 @@ interface 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; + config?: { streamers?: Array<{ name: string }> }; + }; + const showTab = w.showTab; if (typeof showTab !== 'function') { return []; } const tabs: Array<{ id: string; labels: string[]; hint: string }> = [ - { id: 'vods', labels: ['VODs', 'videos', 'streams'], hint: 'Go' }, - { id: 'queue', labels: ['Queue', 'downloads', 'warteschlange'], hint: 'Go' }, - { id: 'streamers', labels: ['Streamers', 'channels'], hint: 'Go' }, - { id: 'stats', labels: ['Stats', 'statistiken', 'dashboard'], hint: 'Go' }, - { id: 'archive', labels: ['Archive', 'archiv'], hint: 'Go' }, - { id: 'settings', labels: ['Settings', 'einstellungen', 'config'], hint: 'Go' }, + { id: 'vods', labels: ['VODs', 'videos', 'streams'], hint: 'Tab' }, + { id: 'queue', labels: ['Queue', 'downloads', 'warteschlange'], hint: 'Tab' }, + { id: 'streamers', labels: ['Streamers', 'channels'], hint: 'Tab' }, + { id: 'stats', labels: ['Stats', 'statistiken', 'dashboard'], hint: 'Tab' }, + { id: 'archive', labels: ['Archive', 'archiv'], hint: 'Tab' }, + { id: 'settings', labels: ['Settings', 'einstellungen', 'config'], hint: 'Tab' }, ]; - return tabs.map(t => ({ + const tabCommands: PaletteCommand[] = tabs.map(t => ({ id: 'tab:' + t.id, label: t.labels[0], hint: t.hint, keywords: t.labels.join(' ').toLowerCase(), 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 {