mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-21 01:05:30 +00:00
fix(frontend): clean up profiles state when playlists are deleted
removePlaylists() filtered the playlists array but never removed the corresponding entries from the profiles map (the @TODO left since the store was introduced). Any component reading profiles[id] after deletion would get undefined and crash with 'undefined is not an object (evaluating P[R].name)'. Fix: build a copy of profiles with the deleted IDs removed and include it in the state update alongside the filtered playlists array. Fixes #1269 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5ea194059b
commit
16f4f0c9ed
1 changed files with 10 additions and 6 deletions
|
|
@ -86,12 +86,16 @@ const usePlaylistsStore = create((set) => ({
|
|||
})),
|
||||
|
||||
removePlaylists: (playlistIds) =>
|
||||
set((state) => ({
|
||||
playlists: state.playlists.filter(
|
||||
(playlist) => !playlistIds.includes(playlist.id)
|
||||
),
|
||||
// @TODO: remove playlist profiles here
|
||||
})),
|
||||
set((state) => {
|
||||
const updatedProfiles = { ...state.profiles };
|
||||
playlistIds.forEach((id) => delete updatedProfiles[id]);
|
||||
return {
|
||||
playlists: state.playlists.filter(
|
||||
(playlist) => !playlistIds.includes(playlist.id)
|
||||
),
|
||||
profiles: updatedProfiles,
|
||||
};
|
||||
}),
|
||||
|
||||
setRefreshProgress: (accountIdOrData, data) =>
|
||||
set((state) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue