2026-03-01 01:39:52 +01:00
|
|
|
import React, { useEffect, useMemo, useRef, useState, useCallback } from 'react';
|
|
|
|
|
import {
|
|
|
|
|
fetchChannels, fetchSounds, playSound, setVolumeLive, getVolume,
|
|
|
|
|
adminStatus, adminLogin, adminLogout, adminDelete, adminRename,
|
|
|
|
|
playUrl, fetchCategories, createCategory, assignCategories, clearBadges,
|
|
|
|
|
updateCategory, deleteCategory, partyStart, partyStop, subscribeEvents,
|
|
|
|
|
getSelectedChannels, setSelectedChannel,
|
|
|
|
|
} from './api';
|
2025-08-09 17:21:01 +02:00
|
|
|
import type { VoiceChannelInfo, Sound, Category } from './types';
|
2025-08-08 03:21:01 +02:00
|
|
|
import { getCookie, setCookie } from './cookies';
|
2025-08-07 23:24:56 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Category Color Palette ── */
|
|
|
|
|
const CAT_PALETTE = [
|
|
|
|
|
'#3b82f6', '#f59e0b', '#8b5cf6', '#ec4899', '#14b8a6',
|
|
|
|
|
'#f97316', '#06b6d4', '#ef4444', '#a855f7', '#84cc16',
|
|
|
|
|
'#d946ef', '#0ea5e9', '#f43f5e', '#10b981',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const THEMES = [
|
|
|
|
|
{ id: 'midnight', label: 'Midnight' },
|
|
|
|
|
{ id: 'daylight', label: 'Daylight' },
|
|
|
|
|
{ id: 'neon', label: 'Neon' },
|
|
|
|
|
{ id: 'vapor', label: 'Vapor' },
|
|
|
|
|
{ id: 'matrix', label: 'Matrix' },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
type Tab = 'all' | 'favorites' | 'recent';
|
2026-03-01 02:03:04 +01:00
|
|
|
type BtnSize = 'S' | 'M' | 'L';
|
|
|
|
|
const BTN_SIZES: { id: BtnSize; label: string }[] = [
|
|
|
|
|
{ id: 'S', label: 'S' },
|
|
|
|
|
{ id: 'M', label: 'M' },
|
|
|
|
|
{ id: 'L', label: 'L' },
|
|
|
|
|
];
|
2026-03-01 01:39:52 +01:00
|
|
|
|
2025-08-07 23:24:56 +02:00
|
|
|
export default function App() {
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── State ── */
|
2025-08-07 23:24:56 +02:00
|
|
|
const [sounds, setSounds] = useState<Sound[]>([]);
|
2026-03-01 01:39:52 +01:00
|
|
|
const [total, setTotal] = useState(0);
|
2025-08-08 01:56:30 +02:00
|
|
|
const [folders, setFolders] = useState<Array<{ key: string; name: string; count: number }>>([]);
|
2025-08-09 17:21:01 +02:00
|
|
|
const [categories, setCategories] = useState<Category[]>([]);
|
2026-03-01 01:39:52 +01:00
|
|
|
|
|
|
|
|
const [activeTab, setActiveTab] = useState<Tab>('all');
|
|
|
|
|
const [activeFolder, setActiveFolder] = useState('');
|
2025-08-07 23:24:56 +02:00
|
|
|
const [query, setQuery] = useState('');
|
2026-02-26 13:47:54 +01:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
const [channels, setChannels] = useState<VoiceChannelInfo[]>([]);
|
|
|
|
|
const [selected, setSelected] = useState('');
|
|
|
|
|
const selectedRef = useRef('');
|
2026-02-26 13:47:54 +01:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
const [volume, setVolume] = useState(1);
|
2025-08-08 03:21:01 +02:00
|
|
|
const [favs, setFavs] = useState<Record<string, boolean>>({});
|
2026-03-01 01:39:52 +01:00
|
|
|
const [theme, setTheme] = useState(() => localStorage.getItem('jb-theme') || 'midnight');
|
2026-03-01 02:03:04 +01:00
|
|
|
const [btnSize, setBtnSize] = useState<BtnSize>(() => (localStorage.getItem('jb-btn-size') as BtnSize) || 'M');
|
2026-03-01 01:39:52 +01:00
|
|
|
const [isAdmin, setIsAdmin] = useState(false);
|
|
|
|
|
const [showAdmin, setShowAdmin] = useState(false);
|
2025-08-09 22:00:57 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
const [chaosMode, setChaosMode] = useState(false);
|
2026-02-26 13:47:54 +01:00
|
|
|
const [partyActiveGuilds, setPartyActiveGuilds] = useState<string[]>([]);
|
2026-03-01 01:39:52 +01:00
|
|
|
const chaosModeRef = useRef(false);
|
2026-02-26 13:47:54 +01:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
const [lastPlayed, setLastPlayed] = useState('');
|
|
|
|
|
const [notification, setNotification] = useState<{ msg: string; type: 'info' | 'error' } | null>(null);
|
2026-02-26 13:47:54 +01:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Refs ── */
|
2025-08-09 15:28:32 +02:00
|
|
|
useEffect(() => { chaosModeRef.current = chaosMode; }, [chaosMode]);
|
2025-08-10 18:54:48 +02:00
|
|
|
useEffect(() => { selectedRef.current = selected; }, [selected]);
|
2025-08-07 23:24:56 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Helpers ── */
|
|
|
|
|
const notify = useCallback((msg: string, type: 'info' | 'error' = 'info') => {
|
2026-02-26 13:47:54 +01:00
|
|
|
setNotification({ msg, type });
|
|
|
|
|
setTimeout(() => setNotification(null), 3000);
|
2026-03-01 01:39:52 +01:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const guildId = selected ? selected.split(':')[0] : '';
|
|
|
|
|
const channelId = selected ? selected.split(':')[1] : '';
|
2026-02-26 13:47:54 +01:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Init ── */
|
2025-08-07 23:24:56 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
(async () => {
|
|
|
|
|
try {
|
2026-03-01 01:39:52 +01:00
|
|
|
const [ch, selMap] = await Promise.all([fetchChannels(), getSelectedChannels()]);
|
|
|
|
|
setChannels(ch);
|
|
|
|
|
if (ch.length) {
|
|
|
|
|
const g = ch[0].guildId;
|
|
|
|
|
const serverCid = selMap[g];
|
|
|
|
|
const match = serverCid && ch.find(x => x.guildId === g && x.channelId === serverCid);
|
|
|
|
|
setSelected(match ? `${g}:${serverCid}` : `${ch[0].guildId}:${ch[0].channelId}`);
|
2025-08-08 02:37:53 +02:00
|
|
|
}
|
2026-03-01 01:39:52 +01:00
|
|
|
} catch (e: any) { notify(e?.message || 'Channel-Fehler', 'error'); }
|
2026-02-26 13:47:54 +01:00
|
|
|
try { setIsAdmin(await adminStatus()); } catch { }
|
2026-03-01 01:39:52 +01:00
|
|
|
try { const c = await fetchCategories(); setCategories(c.categories || []); } catch { }
|
2025-08-07 23:24:56 +02:00
|
|
|
})();
|
2025-08-08 03:17:38 +02:00
|
|
|
}, []);
|
2025-08-07 23:24:56 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Theme ── */
|
2026-02-26 13:47:54 +01:00
|
|
|
useEffect(() => {
|
|
|
|
|
document.body.setAttribute('data-theme', theme);
|
2026-03-01 01:39:52 +01:00
|
|
|
localStorage.setItem('jb-theme', theme);
|
2026-02-26 13:47:54 +01:00
|
|
|
}, [theme]);
|
|
|
|
|
|
2026-03-01 02:03:04 +01:00
|
|
|
/* ── Button Size ── */
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
localStorage.setItem('jb-btn-size', btnSize);
|
|
|
|
|
}, [btnSize]);
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── SSE ── */
|
2025-08-10 00:11:38 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
const unsub = subscribeEvents((msg) => {
|
|
|
|
|
if (msg?.type === 'party') {
|
2026-03-01 01:39:52 +01:00
|
|
|
setPartyActiveGuilds(prev => {
|
2025-08-10 00:11:38 +02:00
|
|
|
const s = new Set(prev);
|
|
|
|
|
if (msg.active) s.add(msg.guildId); else s.delete(msg.guildId);
|
|
|
|
|
return Array.from(s);
|
|
|
|
|
});
|
|
|
|
|
} else if (msg?.type === 'snapshot') {
|
|
|
|
|
setPartyActiveGuilds(Array.isArray(msg.party) ? msg.party : []);
|
2025-08-10 18:47:33 +02:00
|
|
|
try {
|
|
|
|
|
const sel = msg?.selected || {};
|
2026-03-01 01:39:52 +01:00
|
|
|
const g = selectedRef.current?.split(':')[0];
|
|
|
|
|
if (g && sel[g]) setSelected(`${g}:${sel[g]}`);
|
2026-02-26 13:47:54 +01:00
|
|
|
} catch { }
|
2025-08-10 21:15:39 +02:00
|
|
|
try {
|
|
|
|
|
const vols = msg?.volumes || {};
|
2026-03-01 01:39:52 +01:00
|
|
|
const g = selectedRef.current?.split(':')[0];
|
|
|
|
|
if (g && typeof vols[g] === 'number') setVolume(vols[g]);
|
2026-02-26 13:47:54 +01:00
|
|
|
} catch { }
|
2025-08-10 18:47:33 +02:00
|
|
|
} else if (msg?.type === 'channel') {
|
2026-03-01 01:39:52 +01:00
|
|
|
const g = selectedRef.current?.split(':')[0];
|
|
|
|
|
if (msg.guildId === g) setSelected(`${msg.guildId}:${msg.channelId}`);
|
2025-08-10 21:15:39 +02:00
|
|
|
} else if (msg?.type === 'volume') {
|
2026-03-01 01:39:52 +01:00
|
|
|
const g = selectedRef.current?.split(':')[0];
|
|
|
|
|
if (msg.guildId === g && typeof msg.volume === 'number') setVolume(msg.volume);
|
2025-08-10 00:11:38 +02:00
|
|
|
}
|
|
|
|
|
});
|
2026-02-26 13:47:54 +01:00
|
|
|
return () => { try { unsub(); } catch { } };
|
2025-08-10 00:11:38 +02:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-03-01 01:39:52 +01:00
|
|
|
setChaosMode(guildId ? partyActiveGuilds.includes(guildId) : false);
|
2025-08-10 00:11:38 +02:00
|
|
|
}, [selected, partyActiveGuilds]);
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Data Fetch ── */
|
2025-08-08 03:17:38 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
(async () => {
|
2025-08-07 23:24:56 +02:00
|
|
|
try {
|
2026-03-01 01:39:52 +01:00
|
|
|
let folderParam = '__all__';
|
|
|
|
|
if (activeTab === 'recent') folderParam = '__recent__';
|
|
|
|
|
else if (activeFolder) folderParam = activeFolder;
|
|
|
|
|
|
|
|
|
|
const s = await fetchSounds(query, folderParam, undefined, false);
|
2025-08-08 01:40:49 +02:00
|
|
|
setSounds(s.items);
|
|
|
|
|
setTotal(s.total);
|
2025-08-08 01:56:30 +02:00
|
|
|
setFolders(s.folders);
|
2026-03-01 01:39:52 +01:00
|
|
|
} catch (e: any) { notify(e?.message || 'Sounds-Fehler', 'error'); }
|
2025-08-08 03:17:38 +02:00
|
|
|
})();
|
2026-03-01 01:39:52 +01:00
|
|
|
}, [activeTab, activeFolder, query]);
|
2025-08-07 23:24:56 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Favs persistence ── */
|
2025-08-08 03:21:01 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
const c = getCookie('favs');
|
2026-03-01 01:39:52 +01:00
|
|
|
if (c) try { setFavs(JSON.parse(c)); } catch { }
|
2025-08-08 03:21:01 +02:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-02-26 13:47:54 +01:00
|
|
|
try { setCookie('favs', JSON.stringify(favs)); } catch { }
|
2025-08-08 03:21:01 +02:00
|
|
|
}, [favs]);
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Volume sync ── */
|
2025-08-08 02:37:53 +02:00
|
|
|
useEffect(() => {
|
2026-03-01 01:39:52 +01:00
|
|
|
if (selected) {
|
|
|
|
|
(async () => {
|
|
|
|
|
try { const v = await getVolume(guildId); setVolume(v); } catch { }
|
|
|
|
|
})();
|
|
|
|
|
}
|
2025-08-08 02:37:53 +02:00
|
|
|
}, [selected]);
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Actions ── */
|
|
|
|
|
async function handlePlay(s: Sound) {
|
|
|
|
|
if (!selected) return notify('Bitte einen Voice-Channel auswählen', 'error');
|
2025-08-07 23:24:56 +02:00
|
|
|
try {
|
2026-03-01 01:39:52 +01:00
|
|
|
await playSound(s.name, guildId, channelId, volume, s.relativePath);
|
|
|
|
|
setLastPlayed(s.name);
|
|
|
|
|
setTimeout(() => setLastPlayed(''), 4000);
|
|
|
|
|
} catch (e: any) { notify(e?.message || 'Play fehlgeschlagen', 'error'); }
|
2025-08-07 23:24:56 +02:00
|
|
|
}
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
async function handleStop() {
|
|
|
|
|
if (!selected) return;
|
|
|
|
|
try { await fetch(`/api/stop?guildId=${encodeURIComponent(guildId)}`, { method: 'POST' }); } catch { }
|
|
|
|
|
}
|
2025-08-09 13:54:38 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
async function handleRandom() {
|
|
|
|
|
if (!sounds.length || !selected) return;
|
|
|
|
|
const rnd = sounds[Math.floor(Math.random() * sounds.length)];
|
|
|
|
|
handlePlay(rnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function toggleParty() {
|
2025-08-09 13:54:38 +02:00
|
|
|
if (chaosMode) {
|
2026-03-01 01:39:52 +01:00
|
|
|
await handleStop();
|
|
|
|
|
try { await partyStop(guildId); } catch { }
|
2025-08-09 13:54:38 +02:00
|
|
|
} else {
|
2026-03-01 01:39:52 +01:00
|
|
|
if (!selected) return notify('Bitte einen Channel auswählen', 'error');
|
|
|
|
|
try { await partyStart(guildId, channelId); } catch { }
|
2025-08-09 13:54:38 +02:00
|
|
|
}
|
2026-03-01 01:39:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ── Computed ── */
|
|
|
|
|
const displaySounds = useMemo(() => {
|
|
|
|
|
if (activeTab === 'favorites') {
|
|
|
|
|
return sounds.filter(s => favs[s.relativePath ?? s.fileName]);
|
|
|
|
|
}
|
|
|
|
|
return sounds;
|
|
|
|
|
}, [sounds, activeTab, favs]);
|
2025-08-09 13:54:38 +02:00
|
|
|
|
2026-02-26 13:47:54 +01:00
|
|
|
const favCount = useMemo(() => Object.values(favs).filter(Boolean).length, [favs]);
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
const visibleFolders = useMemo(() =>
|
|
|
|
|
folders.filter(f => !['__all__', '__recent__', '__top3__'].includes(f.key)),
|
|
|
|
|
[folders]);
|
|
|
|
|
|
|
|
|
|
const folderColorMap = useMemo(() => {
|
|
|
|
|
const m: Record<string, string> = {};
|
|
|
|
|
visibleFolders.forEach((f, i) => { m[f.key] = CAT_PALETTE[i % CAT_PALETTE.length]; });
|
|
|
|
|
return m;
|
|
|
|
|
}, [visibleFolders]);
|
2025-08-09 13:54:38 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
/* ── Admin State ── */
|
|
|
|
|
const [adminPwd, setAdminPwd] = useState('');
|
|
|
|
|
|
|
|
|
|
async function handleAdminLogin() {
|
|
|
|
|
try {
|
|
|
|
|
const ok = await adminLogin(adminPwd);
|
|
|
|
|
if (ok) { setIsAdmin(true); setAdminPwd(''); notify('Admin eingeloggt'); }
|
|
|
|
|
else notify('Falsches Passwort', 'error');
|
|
|
|
|
} catch { notify('Login fehlgeschlagen', 'error'); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleAdminLogout() {
|
|
|
|
|
try { await adminLogout(); setIsAdmin(false); notify('Ausgeloggt'); } catch { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ── Render ── */
|
2025-08-07 23:24:56 +02:00
|
|
|
return (
|
2026-03-01 02:03:04 +01:00
|
|
|
<div className={`app-shell ${chaosMode ? 'party-active' : ''}`} data-btn-size={btnSize}>
|
2026-03-01 01:39:52 +01:00
|
|
|
|
|
|
|
|
{/* ════════ Header ════════ */}
|
|
|
|
|
<header className="header">
|
|
|
|
|
<div className="logo">JUKEBOX</div>
|
|
|
|
|
|
|
|
|
|
<div className="header-search">
|
|
|
|
|
<span className="material-icons search-icon">search</span>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="Sound suchen..."
|
|
|
|
|
value={query}
|
|
|
|
|
onChange={e => setQuery(e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
{query && (
|
|
|
|
|
<button className="search-clear" onClick={() => setQuery('')}>
|
|
|
|
|
<span className="material-icons" style={{ fontSize: 16 }}>close</span>
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="header-meta">
|
|
|
|
|
<div className="sound-count">
|
|
|
|
|
<strong>{total}</strong> Sounds
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-03-01 02:03:04 +01:00
|
|
|
<div className="size-toggle" title="Button-Größe">
|
|
|
|
|
{BTN_SIZES.map(s => (
|
|
|
|
|
<button
|
|
|
|
|
key={s.id}
|
|
|
|
|
className={`size-opt ${btnSize === s.id ? 'active' : ''}`}
|
|
|
|
|
onClick={() => setBtnSize(s.id)}
|
|
|
|
|
>
|
|
|
|
|
{s.label}
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
<select
|
|
|
|
|
className="select-clean"
|
|
|
|
|
value={theme}
|
|
|
|
|
onChange={e => setTheme(e.target.value)}
|
|
|
|
|
>
|
|
|
|
|
{THEMES.map(t => (
|
|
|
|
|
<option key={t.id} value={t.id}>{t.label}</option>
|
|
|
|
|
))}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
className={`admin-toggle ${isAdmin ? 'is-admin' : ''}`}
|
|
|
|
|
onClick={() => setShowAdmin(true)}
|
|
|
|
|
title="Admin"
|
|
|
|
|
>
|
|
|
|
|
<span className="material-icons" style={{ fontSize: 18 }}>settings</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
{/* ════════ Tab Bar ════════ */}
|
|
|
|
|
<nav className="tab-bar">
|
|
|
|
|
<button
|
|
|
|
|
className={`tab-btn ${activeTab === 'all' ? 'active' : ''}`}
|
|
|
|
|
onClick={() => { setActiveTab('all'); setActiveFolder(''); }}
|
|
|
|
|
>
|
|
|
|
|
<span className="material-icons" style={{ fontSize: 16 }}>library_music</span>
|
|
|
|
|
All Sounds
|
|
|
|
|
<span className="tab-badge">{total}</span>
|
2026-02-26 13:47:54 +01:00
|
|
|
</button>
|
2026-03-01 01:39:52 +01:00
|
|
|
<button
|
|
|
|
|
className={`tab-btn ${activeTab === 'favorites' ? 'active' : ''}`}
|
|
|
|
|
onClick={() => { setActiveTab('favorites'); setActiveFolder(''); }}
|
|
|
|
|
>
|
|
|
|
|
<span className="material-icons" style={{ fontSize: 16 }}>star</span>
|
|
|
|
|
Favorites
|
|
|
|
|
{favCount > 0 && <span className="tab-badge">{favCount}</span>}
|
2026-02-26 13:47:54 +01:00
|
|
|
</button>
|
2026-03-01 01:39:52 +01:00
|
|
|
<button
|
|
|
|
|
className={`tab-btn ${activeTab === 'recent' ? 'active' : ''}`}
|
|
|
|
|
onClick={() => { setActiveTab('recent'); setActiveFolder(''); }}
|
|
|
|
|
>
|
|
|
|
|
<span className="material-icons" style={{ fontSize: 16 }}>schedule</span>
|
|
|
|
|
Recently Added
|
2026-02-26 13:47:54 +01:00
|
|
|
</button>
|
2026-03-01 01:39:52 +01:00
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
{/* ════════ Category Filter ════════ */}
|
|
|
|
|
{activeTab === 'all' && visibleFolders.length > 0 && (
|
|
|
|
|
<div className="category-strip">
|
|
|
|
|
{visibleFolders.map(f => {
|
|
|
|
|
const color = folderColorMap[f.key] || '#888';
|
|
|
|
|
const isActive = activeFolder === f.key;
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={f.key}
|
|
|
|
|
className={`cat-chip ${isActive ? 'active' : ''}`}
|
|
|
|
|
onClick={() => setActiveFolder(isActive ? '' : f.key)}
|
|
|
|
|
style={isActive ? { borderColor: color, color, background: `${color}12` } : undefined}
|
|
|
|
|
>
|
|
|
|
|
<span className="cat-dot" style={{ background: color }} />
|
|
|
|
|
{f.name.replace(/\s*\(\d+\)\s*$/, '')}
|
|
|
|
|
<span style={{ opacity: 0.5, fontSize: 10, fontWeight: 700 }}>{f.count}</span>
|
2025-08-10 18:39:43 +02:00
|
|
|
</button>
|
2026-03-01 01:39:52 +01:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-08-09 17:21:01 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
{/* ════════ Sound Grid ════════ */}
|
|
|
|
|
<div className="sounds-area">
|
|
|
|
|
{displaySounds.length === 0 ? (
|
|
|
|
|
<div className="sounds-empty">
|
|
|
|
|
<span className="material-icons">
|
|
|
|
|
{activeTab === 'favorites' ? 'star_border' : 'music_off'}
|
|
|
|
|
</span>
|
|
|
|
|
<p>
|
|
|
|
|
{activeTab === 'favorites'
|
|
|
|
|
? 'Noch keine Favorites — klick den Stern!'
|
|
|
|
|
: query
|
|
|
|
|
? `Kein Sound für "${query}" gefunden`
|
|
|
|
|
: 'Keine Sounds vorhanden'}
|
|
|
|
|
</p>
|
2025-08-08 21:21:23 +02:00
|
|
|
</div>
|
2026-03-01 01:39:52 +01:00
|
|
|
) : (
|
|
|
|
|
<div className="sounds-grid">
|
|
|
|
|
{displaySounds.map((s, idx) => {
|
|
|
|
|
const key = s.relativePath ?? s.fileName;
|
2026-02-26 13:47:54 +01:00
|
|
|
const isFav = !!favs[key];
|
2026-03-01 01:39:52 +01:00
|
|
|
const color = s.folder ? folderColorMap[s.folder] || '#555' : '#555';
|
|
|
|
|
const isNew = s.badges?.includes('new');
|
|
|
|
|
const isTop = s.badges?.includes('top');
|
|
|
|
|
const isPlaying = lastPlayed === s.name;
|
|
|
|
|
|
2025-08-09 10:40:34 +02:00
|
|
|
return (
|
2026-03-01 01:39:52 +01:00
|
|
|
<button
|
|
|
|
|
key={key}
|
|
|
|
|
className={`sound-btn ${isPlaying ? 'is-playing' : ''}`}
|
|
|
|
|
onClick={() => handlePlay(s)}
|
|
|
|
|
title={`${s.name}${s.folder ? ` (${s.folder})` : ''}`}
|
|
|
|
|
style={{ animationDelay: `${Math.min(idx * 8, 400)}ms` }}
|
|
|
|
|
>
|
|
|
|
|
<span className="cat-bar" style={{ background: color }} />
|
|
|
|
|
<span className="sound-label">{s.name}</span>
|
|
|
|
|
|
|
|
|
|
{isNew && <span className="badge-dot new" />}
|
|
|
|
|
{isTop && !isNew && <span className="badge-dot top" />}
|
|
|
|
|
|
|
|
|
|
<span
|
|
|
|
|
className={`fav-star ${isFav ? 'is-fav' : ''}`}
|
|
|
|
|
onClick={e => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
setFavs(prev => ({ ...prev, [key]: !prev[key] }));
|
|
|
|
|
}}
|
2026-02-26 13:47:54 +01:00
|
|
|
>
|
2026-03-01 01:39:52 +01:00
|
|
|
<span className="material-icons" style={{ fontSize: 14 }}>
|
|
|
|
|
{isFav ? 'star' : 'star_border'}
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
2025-08-09 10:40:34 +02:00
|
|
|
);
|
|
|
|
|
})}
|
2025-08-08 21:21:23 +02:00
|
|
|
</div>
|
2026-03-01 01:39:52 +01:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* ════════ Control Bar ════════ */}
|
|
|
|
|
<div className="control-bar">
|
|
|
|
|
<div className="ctrl-section left">
|
|
|
|
|
<div className="channel-wrap">
|
|
|
|
|
<span className="material-icons">headset_mic</span>
|
2026-02-26 13:47:54 +01:00
|
|
|
<select
|
2026-03-01 01:39:52 +01:00
|
|
|
className="channel-select"
|
2026-02-26 13:47:54 +01:00
|
|
|
value={selected}
|
2026-03-01 01:39:52 +01:00
|
|
|
onChange={async e => {
|
2026-02-26 13:47:54 +01:00
|
|
|
const v = e.target.value;
|
|
|
|
|
setSelected(v);
|
|
|
|
|
try {
|
2026-03-01 01:39:52 +01:00
|
|
|
const [g, c] = v.split(':');
|
|
|
|
|
await setSelectedChannel(g, c);
|
2026-02-26 13:47:54 +01:00
|
|
|
} catch { }
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-03-01 01:39:52 +01:00
|
|
|
<option value="" disabled>Channel...</option>
|
|
|
|
|
{channels.map(c => (
|
2026-02-26 13:47:54 +01:00
|
|
|
<option key={`${c.guildId}:${c.channelId}`} value={`${c.guildId}:${c.channelId}`}>
|
2026-03-01 01:39:52 +01:00
|
|
|
{c.guildName} · {c.channelName}
|
2026-02-26 13:47:54 +01:00
|
|
|
</option>
|
2025-08-09 19:52:45 +02:00
|
|
|
))}
|
2026-02-26 13:47:54 +01:00
|
|
|
</select>
|
|
|
|
|
</div>
|
2026-03-01 01:39:52 +01:00
|
|
|
|
|
|
|
|
{lastPlayed && (
|
|
|
|
|
<div className="now-playing">
|
|
|
|
|
<span className="material-icons" style={{ fontSize: 14, verticalAlign: -2, marginRight: 4 }}>play_arrow</span>
|
|
|
|
|
<span>{lastPlayed}</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-08-08 21:21:23 +02:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
<div className="ctrl-section center">
|
|
|
|
|
<button className="ctrl-btn stop" onClick={handleStop} title="Stop">
|
|
|
|
|
<span className="material-icons">stop</span>
|
|
|
|
|
<span>Stop</span>
|
2026-02-26 13:47:54 +01:00
|
|
|
</button>
|
|
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
<button className="ctrl-btn shuffle" onClick={handleRandom} title="Zufälliger Sound">
|
|
|
|
|
<span className="material-icons">shuffle</span>
|
|
|
|
|
<span>Random</span>
|
2026-02-26 13:47:54 +01:00
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<button
|
2026-03-01 01:39:52 +01:00
|
|
|
className={`ctrl-btn party ${chaosMode ? 'active' : ''}`}
|
|
|
|
|
onClick={toggleParty}
|
|
|
|
|
title="Partymode"
|
2026-02-26 13:47:54 +01:00
|
|
|
>
|
2026-03-01 01:39:52 +01:00
|
|
|
<span className="material-icons">{chaosMode ? 'celebration' : 'auto_awesome'}</span>
|
|
|
|
|
<span>{chaosMode ? 'Party!' : 'Party'}</span>
|
2026-02-26 13:47:54 +01:00
|
|
|
</button>
|
|
|
|
|
</div>
|
2025-08-08 13:14:27 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
<div className="ctrl-section right">
|
|
|
|
|
<div className="volume-wrap">
|
|
|
|
|
<span
|
|
|
|
|
className="material-icons"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
const newVol = volume > 0 ? 0 : 0.5;
|
|
|
|
|
setVolume(newVol);
|
|
|
|
|
if (guildId) setVolumeLive(guildId, newVol).catch(() => {});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{volume === 0 ? 'volume_off' : volume < 0.5 ? 'volume_down' : 'volume_up'}
|
|
|
|
|
</span>
|
2026-02-26 13:47:54 +01:00
|
|
|
<input
|
|
|
|
|
className="volume-slider"
|
|
|
|
|
type="range"
|
|
|
|
|
min={0} max={1} step={0.01}
|
|
|
|
|
value={volume}
|
2026-03-01 01:39:52 +01:00
|
|
|
onChange={async e => {
|
2026-02-26 13:47:54 +01:00
|
|
|
const v = parseFloat(e.target.value);
|
|
|
|
|
setVolume(v);
|
2026-03-01 01:39:52 +01:00
|
|
|
if (guildId) try { await setVolumeLive(guildId, v); } catch { }
|
2026-02-26 13:47:54 +01:00
|
|
|
}}
|
2026-03-01 01:39:52 +01:00
|
|
|
style={{ '--fill': `${Math.round(volume * 100)}%` } as React.CSSProperties}
|
2026-02-26 13:47:54 +01:00
|
|
|
/>
|
2026-03-01 01:39:52 +01:00
|
|
|
<span className="volume-pct">{Math.round(volume * 100)}%</span>
|
2026-02-26 13:47:54 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-08-08 01:56:30 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
{/* ════════ Notification Toast ════════ */}
|
2026-02-26 13:47:54 +01:00
|
|
|
{notification && (
|
2026-03-01 01:39:52 +01:00
|
|
|
<div className={`toast ${notification.type}`}>
|
|
|
|
|
<span className="material-icons" style={{ fontSize: 16 }}>
|
2026-02-26 13:47:54 +01:00
|
|
|
{notification.type === 'error' ? 'error_outline' : 'check_circle'}
|
|
|
|
|
</span>
|
|
|
|
|
{notification.msg}
|
2025-08-08 14:55:12 +02:00
|
|
|
</div>
|
2026-02-26 13:47:54 +01:00
|
|
|
)}
|
2025-08-08 14:55:12 +02:00
|
|
|
|
2026-03-01 01:39:52 +01:00
|
|
|
{/* ════════ Admin Panel Overlay ════════ */}
|
|
|
|
|
{showAdmin && (
|
|
|
|
|
<div className="admin-overlay" onClick={e => { if (e.target === e.currentTarget) setShowAdmin(false); }}>
|
|
|
|
|
<div className="admin-panel">
|
|
|
|
|
<h3>
|
|
|
|
|
Admin
|
|
|
|
|
<button className="admin-close" onClick={() => setShowAdmin(false)}>
|
|
|
|
|
<span className="material-icons" style={{ fontSize: 18 }}>close</span>
|
|
|
|
|
</button>
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
|
|
{!isAdmin ? (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="admin-field">
|
|
|
|
|
<label>Password</label>
|
|
|
|
|
<input
|
|
|
|
|
type="password"
|
|
|
|
|
value={adminPwd}
|
|
|
|
|
onChange={e => setAdminPwd(e.target.value)}
|
|
|
|
|
onKeyDown={e => e.key === 'Enter' && handleAdminLogin()}
|
|
|
|
|
placeholder="Admin-Passwort..."
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<button className="admin-btn primary" onClick={handleAdminLogin}>
|
|
|
|
|
Login
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
|
|
|
<p style={{ fontSize: 13, color: 'var(--text-secondary)' }}>
|
|
|
|
|
Eingeloggt als Admin
|
|
|
|
|
</p>
|
|
|
|
|
<button className="admin-btn outline" onClick={handleAdminLogout}>
|
|
|
|
|
Logout
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-08-08 15:01:53 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|