diff --git a/frontend/src/api.js b/frontend/src/api.js index 6b9f87c4..2c74f3f7 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -715,6 +715,7 @@ export default class API { static async queryStreamsTable(params) { try { API.lastStreamQueryParams = params; + useStreamsTableStore.getState().setLastQueryParams(params); const response = await request( `${host}/api/channels/streams/?${params.toString()}` @@ -729,21 +730,24 @@ export default class API { } static async requeryStreams() { - if (!API.lastStreamQueryParams) { + const params = + useStreamsTableStore.getState().lastQueryParams || + API.lastStreamQueryParams; + if (!params) { return null; } try { const [response, ids] = await Promise.all([ request( - `${host}/api/channels/streams/?${API.lastStreamQueryParams.toString()}` + `${host}/api/channels/streams/?${params.toString()}` ), - API.getAllStreamIds(API.lastStreamQueryParams), + API.getAllStreamIds(params), ]); useStreamsTableStore .getState() - .queryStreams(response, API.lastStreamQueryParams); + .queryStreams(response, params); useStreamsTableStore.getState().setAllQueryIds(ids); return response; diff --git a/frontend/src/store/streamsTable.jsx b/frontend/src/store/streamsTable.jsx index f353acf7..2057a6e2 100644 --- a/frontend/src/store/streamsTable.jsx +++ b/frontend/src/store/streamsTable.jsx @@ -12,6 +12,7 @@ const useStreamsTableStore = create((set) => ({ }, selectedStreamIds: [], allQueryIds: [], + lastQueryParams: null, queryStreams: ({ results, count }, params) => { set(() => ({ @@ -44,6 +45,12 @@ const useStreamsTableStore = create((set) => ({ sorting, })); }, + + setLastQueryParams: (lastQueryParams) => { + set(() => ({ + lastQueryParams, + })); + }, })); export default useStreamsTableStore;