update all row IDs in the store so stream table changes reflect in channel table

This commit is contained in:
dekzter 2025-04-24 18:06:32 -04:00
parent 8625f2e524
commit c5f7b183f1
3 changed files with 16 additions and 4 deletions

View file

@ -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) {

View file

@ -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);

View file

@ -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,