mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-20 16:51:10 +00:00
Update front end when channels are edited.
This commit is contained in:
parent
ba6012b28c
commit
00073698b3
3 changed files with 13 additions and 7 deletions
|
|
@ -406,10 +406,7 @@ export default class API {
|
|||
}
|
||||
);
|
||||
|
||||
// Pass the channels array from the response, not the entire response
|
||||
if (response.channels) {
|
||||
useChannelsStore.getState().updateChannels(response.channels);
|
||||
}
|
||||
// Don't automatically update the store here - let the caller handle it
|
||||
return response;
|
||||
} catch (e) {
|
||||
errorNotification('Failed to update channels', e);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,11 @@ const ChannelBatchForm = ({ channelIds, isOpen, onClose }) => {
|
|||
|
||||
try {
|
||||
await API.updateChannels(channelIds, values);
|
||||
// Refresh both the channels table data and the main channels store
|
||||
await Promise.all([
|
||||
API.requeryChannels(),
|
||||
useChannelsStore.getState().fetchChannels()
|
||||
]);
|
||||
onClose();
|
||||
} catch (error) {
|
||||
console.error('Failed to update channels:', error);
|
||||
|
|
|
|||
|
|
@ -152,14 +152,18 @@ const useChannelsStore = create((set, get) => ({
|
|||
})),
|
||||
|
||||
updateChannels: (channels) => {
|
||||
const channelsByUUID = {};
|
||||
// Ensure channels is an array
|
||||
if (!Array.isArray(channels)) {
|
||||
console.error('updateChannels expects an array, received:', typeof channels, channels);
|
||||
return;
|
||||
} const channelsByUUID = {};
|
||||
const updatedChannels = channels.reduce((acc, chan) => {
|
||||
channelsByUUID[chan.uuid] = chan;
|
||||
channelsByUUID[chan.uuid] = chan.id;
|
||||
acc[chan.id] = chan;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return set((state) => ({
|
||||
set((state) => ({
|
||||
channels: {
|
||||
...state.channels,
|
||||
...updatedChannels,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue