From c5f7b183f153abd8344d65eb38917b918ea274a2 Mon Sep 17 00:00:00 2001 From: dekzter Date: Thu, 24 Apr 2025 18:06:32 -0400 Subject: [PATCH] update all row IDs in the store so stream table changes reflect in channel table --- frontend/src/api.js | 10 +++++++--- frontend/src/components/tables/ChannelsTable.jsx | 3 ++- frontend/src/store/channelsTable.jsx | 7 +++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index b2619427..5c9e415d 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -192,13 +192,17 @@ export default class API { static async requeryChannels() { try { - const response = await request( - `${host}/api/channels/channels/?${API.lastQueryParams.toString()}` - ); + const [response, ids] = await Promise.all([ + request( + `${host}/api/channels/channels/?${API.lastQueryParams.toString()}` + ), + API.getAllChannelIds(API.lastQueryParams), + ]); useChannelsTableStore .getState() .queryChannels(response, API.lastQueryParams); + useChannelsTableStore.getState().setAllQueryIds(ids); return response; } catch (e) { diff --git a/frontend/src/components/tables/ChannelsTable.jsx b/frontend/src/components/tables/ChannelsTable.jsx index dfdfbebd..c3ab40cc 100644 --- a/frontend/src/components/tables/ChannelsTable.jsx +++ b/frontend/src/components/tables/ChannelsTable.jsx @@ -199,6 +199,8 @@ const ChannelsTable = ({}) => { const setSorting = useChannelsTableStore((s) => s.setSorting); const totalCount = useChannelsTableStore((s) => s.totalCount); const setChannelStreams = useChannelsTableStore((s) => s.setChannelStreams); + const allRowIds = useChannelsTableStore((s) => s.allQueryIds); + const setAllRowIds = useChannelsTableStore((s) => s.setAllQueryIds); // store/channels const channels = useChannelsStore((s) => s.channels); @@ -228,7 +230,6 @@ const ChannelsTable = ({}) => { /** * useState */ - const [allRowIds, setAllRowIds] = useState([]); const [channel, setChannel] = useState(null); const [channelModalOpen, setChannelModalOpen] = useState(false); const [recordingModalOpen, setRecordingModalOpen] = useState(false); diff --git a/frontend/src/store/channelsTable.jsx b/frontend/src/store/channelsTable.jsx index 23cba8e4..592e5c86 100644 --- a/frontend/src/store/channelsTable.jsx +++ b/frontend/src/store/channelsTable.jsx @@ -13,6 +13,7 @@ const useChannelsTableStore = create((set, get) => ({ pageSize: 50, }, selectedChannelIds: [], + allQueryIds: [], queryChannels: ({ results, count }, params) => { set((state) => { @@ -24,6 +25,12 @@ const useChannelsTableStore = create((set, get) => ({ }); }, + setAllQueryIds: (allQueryIds) => { + set((state) => ({ + allQueryIds, + })); + }, + setSelectedChannelIds: (selectedChannelIds) => { set({ selectedChannelIds,