diff --git a/src/renderer/features/context-menu/context-menu-provider.tsx b/src/renderer/features/context-menu/context-menu-provider.tsx index 19937b86b..0f43dbc86 100644 --- a/src/renderer/features/context-menu/context-menu-provider.tsx +++ b/src/renderer/features/context-menu/context-menu-provider.tsx @@ -613,10 +613,12 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => { } } + ctx.tableApi?.redrawRows(); + if (isCurrentSongRemoved) { remote?.updateSong({ song: playerData.current.song }); } - }, [ctx.dataNodes, playerType, removeFromQueue]); + }, [ctx.dataNodes, ctx.tableApi, playerType, removeFromQueue]); const handleDeselectAll = useCallback(() => { ctx.tableApi?.deselectAll(); diff --git a/src/renderer/store/player.store.ts b/src/renderer/store/player.store.ts index dcbf190af..1bc06d878 100644 --- a/src/renderer/store/player.store.ts +++ b/src/renderer/store/player.store.ts @@ -631,10 +631,17 @@ export const usePlayerStore = create()( removeFromQueue: (uniqueIds) => { const queue = get().queue.default; const currentSong = get().current.song; + const currentPosition = get().current.index; + let queueShift = 0; - const newQueue = queue.filter( - (song) => !uniqueIds.includes(song.uniqueId), - ); + const newQueue = queue.filter((song, index) => { + const shouldKeep = !uniqueIds.includes(song.uniqueId); + if (!shouldKeep && index < currentPosition) { + queueShift += 1; + } + + return shouldKeep; + }); const newShuffledQueue = get().queue.shuffled.filter( (uniqueId) => !uniqueIds.includes(uniqueId), ); @@ -648,6 +655,10 @@ export const usePlayerStore = create()( if (isCurrentSongRemoved) { state.current.song = newQueue[0]; state.current.index = 0; + } else { + // if we removed any songs prior to the current one, + // shift the index back as necessary + state.current.index -= queueShift; } });