mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 00:55:50 +00:00
better handling of profiles and updating the necessary properties for other components
This commit is contained in:
parent
a41b205629
commit
d2dbbcc136
2 changed files with 43 additions and 12 deletions
|
|
@ -312,8 +312,12 @@ const ChannelsTable = ({}) => {
|
|||
() => [
|
||||
{
|
||||
id: 'enabled',
|
||||
header: <ScanEye size="16" />,
|
||||
size: 40,
|
||||
header: (
|
||||
<Box style={{ paddingLeft: 10 }}>
|
||||
<ScanEye size="16" />
|
||||
</Box>
|
||||
),
|
||||
size: 50,
|
||||
enableSorting: false,
|
||||
accessorFn: (row) => {
|
||||
if (selectedProfileId == '0') {
|
||||
|
|
|
|||
|
|
@ -74,16 +74,32 @@ const useChannelsStore = create((set, get) => ({
|
|||
|
||||
addChannel: (newChannel) => {
|
||||
get().fetchChannelProfiles();
|
||||
set((state) => ({
|
||||
channels: {
|
||||
...state.channels,
|
||||
[newChannel.id]: newChannel,
|
||||
},
|
||||
channelsByUUID: {
|
||||
...state.channelsByUUID,
|
||||
[newChannel.uuid]: newChannel.id,
|
||||
},
|
||||
}));
|
||||
set((state) => {
|
||||
const profiles = { ...state.profiles };
|
||||
Object.values(profiles).forEach((item) => {
|
||||
item.channels.push({
|
||||
id: newChannel.id,
|
||||
enabled: true,
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
channels: {
|
||||
...state.channels,
|
||||
[newChannel.id]: newChannel,
|
||||
},
|
||||
channelsByUUID: {
|
||||
...state.channelsByUUID,
|
||||
[newChannel.uuid]: newChannel.id,
|
||||
},
|
||||
profiles,
|
||||
selectedProfile: profiles[state.selectedProfileId],
|
||||
selectedProfileChannels:
|
||||
state.selectedProfileId == '0'
|
||||
? []
|
||||
: profiles[state.selectedProfileId].channels,
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
addChannels: (newChannels) => {
|
||||
|
|
@ -98,6 +114,14 @@ const useChannelsStore = create((set, get) => ({
|
|||
}
|
||||
return acc;
|
||||
}, {});
|
||||
const profileChannels = newChannels.map((channel) => ({
|
||||
id: channel.id,
|
||||
enabled: true,
|
||||
}));
|
||||
const profiles = { ...state.profiles };
|
||||
Object.values(profiles).forEach((item) => {
|
||||
item.channels.concat(profileChannels); // Append a new channel object
|
||||
});
|
||||
return set((state) => ({
|
||||
channels: {
|
||||
...state.channels,
|
||||
|
|
@ -111,6 +135,9 @@ const useChannelsStore = create((set, get) => ({
|
|||
...state.logos,
|
||||
...logos,
|
||||
},
|
||||
profiles,
|
||||
selectedProfile: profiles[state.selectedProfileId],
|
||||
selectedProfileChannels: profiles[state.selectedProfileId].channels,
|
||||
}));
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue