mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
feat(player): queue undo/redo with hotkeys and playback-aware restore
Snapshot queue, current track, time, and pause before queue mutations. Ctrl+Z/Cmd+Z restores prior state; Ctrl+Shift+Z/Cmd+Shift+Z reapplies undone edits when the redo stack is non-empty; new edits clear redo. Resync the Rust audio engine only when the current song identity changes from the pre-apply state so reorder/enqueue-style edits keep live playback. Register the document capture listener from main.tsx after the window label is set. Mini player forwards undo/redo via mini:undo-queue and mini:redo-queue.
This commit is contained in:
@@ -198,6 +198,14 @@ export function initMiniPlayerBridgeOnMain(): () => void {
|
||||
usePlayerStore.getState().shuffleQueue();
|
||||
});
|
||||
|
||||
const undoQueueUnlisten = listen('mini:undo-queue', () => {
|
||||
usePlayerStore.getState().undoLastQueueEdit();
|
||||
});
|
||||
|
||||
const redoQueueUnlisten = listen('mini:redo-queue', () => {
|
||||
usePlayerStore.getState().redoLastQueueEdit();
|
||||
});
|
||||
|
||||
// Gapless ↔ Crossfade are mutually exclusive (see CLAUDE.md). Bridge handles
|
||||
// the exclusion so the mini doesn't need to know about both states to act.
|
||||
const gaplessUnlisten = listen<{ value: boolean }>('mini:set-gapless', (e) => {
|
||||
@@ -241,6 +249,8 @@ export function initMiniPlayerBridgeOnMain(): () => void {
|
||||
navigateUnlisten.then(fn => fn()).catch(() => {});
|
||||
volumeUnlisten.then(fn => fn()).catch(() => {});
|
||||
shuffleUnlisten.then(fn => fn()).catch(() => {});
|
||||
undoQueueUnlisten.then(fn => fn()).catch(() => {});
|
||||
redoQueueUnlisten.then(fn => fn()).catch(() => {});
|
||||
gaplessUnlisten.then(fn => fn()).catch(() => {});
|
||||
crossfadeUnlisten.then(fn => fn()).catch(() => {});
|
||||
infiniteQueueUnlisten.then(fn => fn()).catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user