Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-12 02:57:35 +03:00
1 parent 9574aa8a23
commit 1c96d5973b
13 files changed
+437 -1

No files matched your search

+3
View File
@@ -19,6 +19,7 @@ import { StatsView } from './views/StatsView';
import { WatchView } from './views/WatchView';
import { ServerView } from './views/ServerView';
import { RpcView } from './views/RpcView';
import { RoomsView } from './views/RoomsView';
const HEADS: Record<string, [string, string]> = {
now: ['Now Playing', 'What Echoion is streaming to the channel'],
@@ -26,6 +27,7 @@ const HEADS: Record<string, [string, string]> = {
search: ['Search', 'Find tracks across YouTube and Yandex Music'],
library: ['Library', 'Your favorites and saved playlists'],
stats: ['History & Stats', 'Playback history and server insights'],
rooms: ['Listening Rooms', 'Independent music streams for different groups'],
watch: ['Watch Together', 'Synced viewing room — everyone in step'],
server: ['Server & Admin', 'Manage subscribers and broadcast'],
rpc: ['RPC / API', 'Connect to Echoion programmatically'],
@@ -102,6 +104,7 @@ export function App() {
{s.view === 'search' && <SearchView />}
{s.view === 'library' && <LibraryView />}
{s.view === 'stats' && <StatsView />}
{s.view === 'rooms' && <RoomsView />}
{/* The watch view stays mounted so the embedded player and
room connection survive view switches (the old UI only
toggled `hidden`). */}
+2
View File
@@ -18,6 +18,7 @@ import {
HeartIcon,
PlayIcon,
QueueIcon,
RoomsIcon,
SearchIcon,
StatsIcon,
WatchIcon,
@@ -30,6 +31,7 @@ const NAV: Array<{ view: ViewName; icon: ReactNode; label: string }> = [
{ view: 'search', icon: <SearchIcon />, label: 'Search' },
{ view: 'library', icon: <HeartIcon />, label: 'Library' },
{ view: 'stats', icon: <StatsIcon />, label: 'History & Stats' },
{ view: 'rooms', icon: <RoomsIcon />, label: 'Listening Rooms' },
{ view: 'watch', icon: <WatchIcon />, label: 'Watch Together' },
{ view: 'server', icon: <GearIcon />, label: 'Server & Admin' },
{ view: 'rpc', icon: <CodeIcon />, label: 'RPC / API' },
+5
View File
@@ -57,6 +57,9 @@ export const StatsIcon = makeIcon(
export const WatchIcon = makeIcon(
'M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V6h16v12zM9.5 8.5l7 3.5-7 3.5v-7z'
);
export const RoomsIcon = makeIcon(
'M4 4h6v6H4V4zm10 0h6v6h-6V4zM4 14h6v6H4v-6zm10 0h6v6h-6v-6z'
);
export const GearIcon = makeIcon(
'M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z'
);
@@ -76,6 +79,8 @@ export const RefreshIcon = makeIcon(
'M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z'
);
export const PlusIcon = makeIcon('M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z');
export const ArrowUpIcon = makeIcon('M4 12l1.41 1.41L11 7.83V20h2V7.83l5.59 5.58L20 12l-8-8-8 8z');
export const ArrowDownIcon = makeIcon('M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.59-5.58L4 12l8 8 8-8z');
export const VolumeIcon = makeIcon(
'M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'
);
+42
View File
@@ -10,6 +10,9 @@ export const ru: Record<string, string> = {
'Library': 'Библиотека',
'History & Stats': 'История и статистика',
'Watch Together': 'Совместный просмотр',
'Listening Rooms': 'Комнаты прослушивания',
'Independent music streams for different groups':
'Независимые музыкальные потоки для разных групп',
'Server & Admin': 'Сервер и админ',
'RPC / API': 'RPC / API',
'MUSIC BOT · TS3': 'МУЗЫКАЛЬНЫЙ БОТ · TS3',
@@ -286,6 +289,45 @@ export const ru: Record<string, string> = {
'Playlist name': 'Название плейлиста',
'Save playlist': 'Сохранить плейлист',
// Independent TeamSpeak listening rooms
'MULTI-STREAM': 'МУЛЬТИПОТОК',
'NOW TUNED': 'СЕЙЧАС В КОМНАТЕ',
'Your channel, split into listening spaces':
'Разделите канал на пространства для прослушивания',
'Each room has its own queue and bot stream. Join one to hear and control it.':
'У каждой комнаты своя очередь и поток бота. Войдите, чтобы слушать и управлять.',
'Room name': 'Название комнаты',
'Create room': 'Создать комнату',
'Created room “{0}”': 'Комната «{0}» создана',
'Live rooms': 'Активные комнаты',
'No listening rooms yet': 'Комнат прослушивания пока нет',
'{0} listeners · {1} queued': '{0} слушателей · {1} в очереди',
'JOINED': 'ВЫ В КОМНАТЕ',
'PAUSED': 'ПАУЗА',
'IDLE': 'ТИШИНА',
'Choose a room': 'Выберите комнату',
'Your TeamSpeak audio follows the room you join.':
'Звук TeamSpeak переключается на комнату, в которую вы вошли.',
'Leave': 'Выйти',
'Delete room': 'Удалить комнату',
'Delete “{0}” for everyone?': 'Удалить «{0}» для всех?',
'Stop': 'Остановить',
'Skip': 'Пропустить',
'Move up': 'Переместить выше',
'Move down': 'Переместить ниже',
'Pause': 'Пауза',
'Resume': 'Продолжить',
'Paused': 'На паузе',
'Streaming now': 'Сейчас транслируется',
'Ready': 'Готово',
'{0} people are tuned in': 'Подключено: {0}',
'Paste a URL or search for a track…':
'Вставьте ссылку или найдите трек…',
'Add': 'Добавить',
'Added to room queue': 'Добавлено в очередь комнаты',
'Room queue': 'Очередь комнаты',
'This room queue is empty': 'Очередь этой комнаты пуста',
// Controllable embeds (Kodik / Playerjs)
'Embed synced': 'Встраиваемый плеер синхронизирован',
'Embed is view-only': 'Встраиваемый плеер — только просмотр',
+1
View File
@@ -22,6 +22,7 @@ export type ViewName =
| 'search'
| 'library'
| 'stats'
| 'rooms'
| 'watch'
| 'server'
| 'rpc';
+11
View File
@@ -0,0 +1,11 @@
import { describe, expect, it } from 'vitest';
import { auditMethodName } from './auditMethods';
describe('audit RPC method mapping', () => {
it('keeps listening-room methods append-only and aligned with RpcTypes.hpp', () => {
expect(auditMethodName(53)).toBe('ListListeningRooms');
expect(auditMethodName(62)).toBe('GetListeningRoomQueue');
expect(auditMethodName(63)).toBe('SkipListeningRoom');
expect(auditMethodName(66)).toBe('ClearListeningRoomQueue');
});
});
+14
View File
@@ -58,6 +58,20 @@ const RPC_METHOD_BY_INDEX: readonly string[] = [
'AddCustomEmoji', // 50
'RemoveCustomEmoji',
'GetLyrics',
'ListListeningRooms',
'CreateListeningRoom',
'DeleteListeningRoom',
'JoinListeningRoom',
'LeaveListeningRoom',
'PlayInListeningRoom',
'PauseListeningRoom',
'ResumeListeningRoom',
'StopListeningRoom',
'GetListeningRoomQueue',
'SkipListeningRoom',
'RemoveFromListeningRoomQueue',
'MoveInListeningRoomQueue',
'ClearListeningRoomQueue',
];
export function auditMethodName(method: number): string {
+1
View File
@@ -13,6 +13,7 @@ const VIEWS: readonly ViewName[] = [
'search',
'library',
'stats',
'rooms',
'watch',
'server',
'rpc',
+14
View File
@@ -139,4 +139,18 @@ describe('RpcClient wire contract', () => {
});
expect(seen).toEqual([['queue.updated', { size: 3 }]]);
});
it('unsubscribes a notification listener', async () => {
installFakes();
const rpc = new RpcClient();
await rpc.connect();
const ws = FakeWebSocket.instances[0];
const seen: unknown[] = [];
const unsubscribe = rpc.on('listening_rooms.updated', (data) =>
seen.push(data)
);
unsubscribe();
ws.receive({ event: 'listening_rooms.updated', data: '{}' });
expect(seen).toEqual([]);
});
});
+23 -1
View File
@@ -64,7 +64,22 @@ export type RpcMethodName =
| 'SetUserPrefs'
| 'GetCustomEmojis'
| 'AddCustomEmoji'
| 'RemoveCustomEmoji';
| 'RemoveCustomEmoji'
| 'ListListeningRooms'
| 'CreateListeningRoom'
| 'DeleteListeningRoom'
| 'JoinListeningRoom'
| 'LeaveListeningRoom'
| 'PlayInListeningRoom'
| 'PauseListeningRoom'
| 'ResumeListeningRoom'
| 'StopListeningRoom'
| 'GetListeningRoomQueue'
| 'SkipListeningRoom'
| 'RemoveFromListeningRoomQueue'
| 'MoveInListeningRoomQueue'
| 'ClearListeningRoomQueue';
type Pending = {
resolve: (value: unknown) => void;
@@ -226,6 +241,13 @@ export class RpcClient {
on(event: string, cb: (...args: unknown[]) => void) {
if (!this.listeners.has(event)) this.listeners.set(event, []);
this.listeners.get(event)!.push(cb);
return () => {
const listeners = this.listeners.get(event);
if (!listeners) return;
const index = listeners.indexOf(cb);
if (index >= 0) listeners.splice(index, 1);
if (listeners.length === 0) this.listeners.delete(event);
};
}
authenticate(token: string) {
+15
View File
@@ -19,6 +19,21 @@ export interface QueueEntry {
addedBy?: string;
}
export interface ListeningRoom {
name: string;
ownerId: number;
members: number[];
isPlaying: boolean;
isPaused: boolean;
queueSize: number;
isOwner: boolean;
}
export interface ListeningRoomList {
rooms: ListeningRoom[];
currentRoom?: string;
}
export interface Status {
isPlaying?: boolean;
isPaused?: boolean;
+62
View File
@@ -739,6 +739,68 @@ select:focus:not(:focus-visible) { outline: none; }
.rooms-create { display: flex; gap: 8px; }
.rooms-create input { flex: 1; }
/* ── Independent listening rooms ─────────────────────────────────────── */
.listening-rooms-view { --room-cyan: #61e4d8; --room-cyan-soft: rgba(97, 228, 216, .12); }
.rooms-hero {
display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
gap: 28px; align-items: end; margin-bottom: 18px; padding: 24px;
border: 1px solid rgba(97, 228, 216, .15); border-radius: 18px;
background: radial-gradient(circle at 92% 8%, rgba(97, 228, 216, .14), transparent 34%), linear-gradient(115deg, rgba(124, 92, 255, .11), rgba(255, 255, 255, .025));
position: relative; overflow: hidden;
}
.rooms-hero::after {
content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .22;
background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
background-size: 28px 28px; mask-image: linear-gradient(90deg, transparent, #000);
}
.rooms-hero > * { position: relative; z-index: 1; }
.rooms-hero h2 { font-size: clamp(20px, 2.5vw, 31px); max-width: 620px; letter-spacing: -.035em; }
.rooms-hero p { color: var(--muted); line-height: 1.55; max-width: 620px; margin-top: 8px; }
.rooms-kicker { display: block; margin-bottom: 7px; color: var(--room-cyan); font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .18em; }
.listening-room-create { display: flex; gap: 8px; }
.listening-room-create input { flex: 1; min-width: 0; }
.listening-room-create .btn, .room-play-form .btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.listening-room-grid { display: grid; grid-template-columns: minmax(260px, .7fr) minmax(0, 1.3fr); gap: 18px; align-items: start; }
.room-directory, .room-console { min-height: 440px; }
.listening-room-list { display: flex; flex-direction: column; gap: 8px; }
.listening-room-card { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px; text-align: left; color: var(--text-2); background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.055); border-radius: 11px; cursor: pointer; transition: border-color .16s, background .16s, transform .16s; }
.listening-room-card:hover { transform: translateX(2px); border-color: rgba(97,228,216,.22); background: rgba(97,228,216,.045); }
.listening-room-card.active { border-color: rgba(97,228,216,.5); background: var(--room-cyan-soft); box-shadow: inset 3px 0 0 var(--room-cyan); }
.room-signal { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px rgba(255,255,255,.025); }
.room-signal.playing { background: var(--room-cyan); box-shadow: 0 0 0 4px rgba(97,228,216,.1), 0 0 14px rgba(97,228,216,.45); animation: ech-pulse 1.6s infinite; }
.room-card-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.room-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card-copy small { color: var(--muted-2); }
.room-state { font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: .1em; color: var(--room-cyan); }
.room-console { position: relative; overflow: hidden; }
.room-console::before { content: ''; position: absolute; top: 0; right: 0; width: 180px; height: 180px; background: radial-gradient(circle at top right, rgba(124,92,255,.1), transparent 68%); pointer-events: none; }
.room-console-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; position: relative; }
.room-console-head h2 { font-size: 25px; }
.room-console-empty { min-height: 390px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); }
.room-console-empty h2 { color: var(--text); margin: 8px 0 5px; }
.room-console-glyph { font-family: var(--font-mono); font-size: 54px; font-weight: 700; color: rgba(97,228,216,.15); letter-spacing: -.12em; }
.room-transport { display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 14px; border: 1px solid rgba(97,228,216,.12); border-radius: 13px; background: linear-gradient(90deg, rgba(97,228,216,.07), rgba(255,255,255,.025)); }
.room-transport .ctrl-main { background: var(--room-cyan); color: #061715; box-shadow: 0 5px 22px rgba(97,228,216,.22); }
.stop-square { width: 9px; height: 9px; background: currentColor; border-radius: 1px; }
.room-transport-copy { display: flex; flex-direction: column; gap: 2px; }
.room-transport-copy small { color: var(--muted-2); }
.room-play-form { display: flex; gap: 8px; margin-bottom: 20px; }
.room-play-form input { flex: 1; min-width: 0; }
.room-queue-head { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 16px; margin-bottom: 5px; }
.room-queue-head span { color: var(--muted-2); font-family: var(--font-mono); font-size: 11px; }
.room-tracklist { max-height: 330px; overflow-y: auto; }
@media (max-width: 1080px) {
.listening-room-grid { grid-template-columns: 1fr; }
.room-directory, .room-console { min-height: 0; }
}
@media (max-width: 560px) {
.rooms-hero { grid-template-columns: 1fr; padding: 18px; }
.listening-room-create, .room-play-form { flex-wrap: wrap; }
.listening-room-create input, .room-play-form input { flex-basis: 100%; }
.room-console-head { flex-direction: column; }
}
/* Watch search (item 20). */
.watch-search { position: relative; margin-bottom: 8px; }
.watch-search-results {
+244
View File
@@ -0,0 +1,244 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { safeCall, toast } from '../lib/app';
import type {
ListeningRoom,
ListeningRoomList,
QueueEntry,
} from '../lib/types';
import { confirmDialog } from '../lib/dialog';
import {
CloseIcon,
ArrowDownIcon,
ArrowUpIcon,
PauseIcon,
PlayIcon,
PlusIcon,
RefreshIcon,
SkipNextIcon,
} from '../components/icons';
import { EmptyRow, TrackRow } from '../components/TrackRow';
import { t, tf } from '../i18n';
import { rpc } from '../lib/rpc';
export function RoomsView() {
const [rooms, setRooms] = useState<ListeningRoom[]>([]);
const [currentRoom, setCurrentRoom] = useState<string | null>(null);
const [queue, setQueue] = useState<QueueEntry[]>([]);
const [roomName, setRoomName] = useState('');
const [query, setQuery] = useState('');
const [busy, setBusy] = useState(false);
const current = useMemo(
() => rooms.find((room) => room.name === currentRoom) || null,
[rooms, currentRoom]
);
const refresh = useCallback(async () => {
const result = await safeCall<ListeningRoomList>('ListListeningRooms');
if (!result) return;
setRooms(result.rooms || []);
setCurrentRoom(result.currentRoom || null);
if (result.currentRoom) {
const queueResult = await safeCall<{ queue?: QueueEntry[] }>(
'GetListeningRoomQueue',
{ room: result.currentRoom }
);
setQueue(queueResult?.queue || []);
} else {
setQueue([]);
}
}, []);
useEffect(() => {
void refresh();
const unsubscribe = rpc.on('listening_rooms.updated', () => void refresh());
const timer = window.setInterval(refresh, 30000);
return () => {
unsubscribe();
window.clearInterval(timer);
};
}, [refresh]);
const action = async (
method:
| 'JoinListeningRoom'
| 'LeaveListeningRoom'
| 'PauseListeningRoom'
| 'ResumeListeningRoom'
| 'StopListeningRoom'
| 'SkipListeningRoom'
| 'ClearListeningRoomQueue',
room?: string
) => {
setBusy(true);
const result = await safeCall(method, room ? { room } : undefined);
setBusy(false);
if (result) await refresh();
};
return (
<section className="view listening-rooms-view" id="view-rooms">
<div className="rooms-hero">
<div>
<span className="rooms-kicker">{t('MULTI-STREAM')}</span>
<h2>{t('Your channel, split into listening spaces')}</h2>
<p>
{t(
'Each room has its own queue and bot stream. Join one to hear and control it.'
)}
</p>
</div>
<form
className="listening-room-create"
onSubmit={async (event) => {
event.preventDefault();
const name = roomName.trim();
if (!name) return;
setBusy(true);
const result = await safeCall('CreateListeningRoom', {
room: name,
});
setBusy(false);
if (result) {
setRoomName('');
toast(tf('Created room “{0}”', name));
await refresh();
}
}}
>
<input
value={roomName}
onChange={(event) => setRoomName(event.target.value)}
placeholder={t('Room name')}
maxLength={48}
/>
<button className="btn btn-accent" disabled={busy || !roomName.trim()}>
<PlusIcon /> {t('Create room')}
</button>
</form>
</div>
<div className="listening-room-grid">
<div className="card room-directory">
<div className="card-head">
<h2>{t('Live rooms')}</h2>
<button className="icon-btn" onClick={refresh} title={t('Refresh rooms')}>
<RefreshIcon />
</button>
</div>
{rooms.length === 0 ? (
<EmptyRow text={t('No listening rooms yet')} />
) : (
<div className="listening-room-list">
{rooms.map((room) => {
const selected = room.name === currentRoom;
return (
<button
key={room.name}
className={'listening-room-card' + (selected ? ' active' : '')}
disabled={busy}
onClick={() => !selected && action('JoinListeningRoom', room.name)}
>
<span className={'room-signal' + (room.isPlaying ? ' playing' : '')} />
<span className="room-card-copy">
<strong>{room.name}</strong>
<small>
{tf('{0} listeners · {1} queued', room.members.length, room.queueSize)}
</small>
</span>
<span className="room-state">
{selected ? t('JOINED') : room.isPaused ? t('PAUSED') : room.isPlaying ? t('LIVE') : t('IDLE')}
</span>
</button>
);
})}
</div>
)}
</div>
<div className="card room-console">
{!current ? (
<div className="room-console-empty">
<span className="room-console-glyph">04</span>
<h2>{t('Choose a room')}</h2>
<p>{t('Your TeamSpeak audio follows the room you join.')}</p>
</div>
) : (
<>
<div className="room-console-head">
<div>
<span className="rooms-kicker">{t('NOW TUNED')}</span>
<h2>{current.name}</h2>
</div>
<div className="row-gap">
<button className="btn btn-ghost" onClick={() => action('LeaveListeningRoom')} disabled={busy}>
{t('Leave')}
</button>
{current.isOwner && (
<button
className="btn btn-danger-ghost"
onClick={async () => {
if (!(await confirmDialog({ title: t('Delete room'), message: tf('Delete “{0}” for everyone?', current.name), confirmLabel: t('Delete'), danger: true }))) return;
const result = await safeCall('DeleteListeningRoom', { room: current.name });
if (result) await refresh();
}}
>
<CloseIcon /> {t('Delete')}
</button>
)}
</div>
</div>
<div className="room-transport">
<button className="ctrl" title={t('Stop')} onClick={() => action('StopListeningRoom', current.name)}><span className="stop-square" /></button>
<button
className="ctrl ctrl-main"
title={current.isPlaying && !current.isPaused ? t('Pause') : t('Resume')}
onClick={() => action(current.isPlaying && !current.isPaused ? 'PauseListeningRoom' : 'ResumeListeningRoom', current.name)}
>
{current.isPlaying && !current.isPaused ? <PauseIcon /> : <PlayIcon />}
</button>
<button className="ctrl" title={t('Skip')} onClick={() => action('SkipListeningRoom', current.name)}><SkipNextIcon /></button>
<div className="room-transport-copy">
<strong>{current.isPlaying ? (current.isPaused ? t('Paused') : t('Streaming now')) : t('Ready')}</strong>
<small>{tf('{0} people are tuned in', current.members.length)}</small>
</div>
</div>
<form
className="room-play-form"
onSubmit={async (event) => {
event.preventDefault();
const value = query.trim();
if (!value) return;
const result = await safeCall<{ message?: string }>('PlayInListeningRoom', { room: current.name, query: value });
if (result) { setQuery(''); toast(result.message || t('Added to room queue')); await refresh(); }
}}
>
<input value={query} onChange={(event) => setQuery(event.target.value)} placeholder={t('Paste a URL or search for a track…')} />
<button className="btn btn-accent" disabled={!query.trim()}><PlusIcon /> {t('Add')}</button>
</form>
<div className="room-queue-head">
<h3>{t('Room queue')}</h3>
<div className="row-gap">
<span>{tf('{0} tracks', queue.length)}</span>
{!!queue.length && <button className="btn btn-danger-ghost" onClick={() => action('ClearListeningRoomQueue', current.name)}>{t('Clear')}</button>}
</div>
</div>
<div className="tracklist room-tracklist">
{queue.length ? queue.map((entry, index) => (
<TrackRow key={entry.queueId} track={entry.track} num={index + 1} playing={entry.isPlaying} actions={[
index > 0 && { icon: <ArrowUpIcon />, title: t('Move up'), onClick: async () => { await safeCall('MoveInListeningRoomQueue', { room: current.name, queueId: entry.queueId, newPosition: index - 1 }); await refresh(); } },
index + 1 < queue.length && { icon: <ArrowDownIcon />, title: t('Move down'), onClick: async () => { await safeCall('MoveInListeningRoomQueue', { room: current.name, queueId: entry.queueId, newPosition: index + 1 }); await refresh(); } },
{ icon: <CloseIcon />, title: t('Remove'), cls: 'danger', onClick: async () => { await safeCall('RemoveFromListeningRoomQueue', { room: current.name, queueId: entry.queueId }); await refresh(); } },
]} />
)) : <EmptyRow text={t('This room queue is empty')} />}
</div>
</>
)}
</div>
</div>
</section>
);
}