mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-08-03 07:12:30 +00:00
Fixes user state not updating when editing channels.
This commit is contained in:
parent
42db972e07
commit
4803a3605e
2 changed files with 28 additions and 1 deletions
|
|
@ -1321,4 +1321,14 @@ export default class API {
|
|||
errorNotification('Failed to update channel EPGs', e);
|
||||
}
|
||||
}
|
||||
|
||||
static async getChannel(id) {
|
||||
try {
|
||||
const response = await request(`${host}/api/channels/channels/${id}/?include_streams=true`);
|
||||
return response;
|
||||
} catch (e) {
|
||||
errorNotification('Failed to fetch channel details', e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,10 +352,27 @@ const ChannelsTable = ({ }) => {
|
|||
const editChannel = async (ch = null) => {
|
||||
if (ch) {
|
||||
console.log(`Opening editor for channel: ${ch.name} (${ch.id})`);
|
||||
|
||||
try {
|
||||
// Fetch the full channel with streams data directly from the API instead of the store
|
||||
const fullChannelData = await API.getChannel(ch.id);
|
||||
if (fullChannelData) {
|
||||
setChannel(fullChannelData);
|
||||
} else {
|
||||
// Fallback to store data if API call fails
|
||||
const latestChannel = useChannelsStore.getState().channels[ch.id];
|
||||
setChannel(latestChannel);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching channel data:", error);
|
||||
// Fallback to store data if API call fails
|
||||
const latestChannel = useChannelsStore.getState().channels[ch.id];
|
||||
setChannel(latestChannel);
|
||||
}
|
||||
} else {
|
||||
console.log('Creating new channel');
|
||||
setChannel(null);
|
||||
}
|
||||
setChannel(ch);
|
||||
setChannelModalOpen(true);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue