chore(orbit): guard bulk queue operations

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Psychotoxical
2026-04-24 11:24:46 +02:00
parent f8bcd57ed4
commit 7ba7d6bf25
9 changed files with 191 additions and 7 deletions
+26
View File
@@ -0,0 +1,26 @@
import { useOrbitStore } from '../store/orbitStore';
import { useConfirmModalStore } from '../store/confirmModalStore';
import i18n from '../i18n';
/**
* Ask the user before dropping many tracks into the shared Orbit queue.
*
* Returns `true` when there's no active Orbit session, when `count <= 1`, or
* when the user accepted the confirm dialog. Returns `false` only when an
* active-Orbit user explicitly cancelled.
*
* Lives in its own module so `playerStore` can use it without pulling the
* full `utils/orbit.ts` (which itself imports `playerStore` — circular).
*/
export async function orbitBulkGuard(count: number): Promise<boolean> {
const role = useOrbitStore.getState().role;
if (role !== 'host' && role !== 'guest') return true;
if (count <= 1) return true;
return useConfirmModalStore.getState().request({
title: i18n.t('orbit.bulkConfirmTitle'),
message: i18n.t('orbit.bulkConfirmBody', { count }),
confirmLabel: i18n.t('orbit.bulkConfirmYes'),
cancelLabel: i18n.t('orbit.bulkConfirmNo'),
});
}