Skip to content

Commit

Permalink
Fix duplicate GroupView call in Collection (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithmohan authored Dec 21, 2023
1 parent 68a2377 commit 29ff1ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/core/react-query/webui/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import type {
WebuiTheme,
} from '@/core/types/api/webui';

export const useGroupViewQuery = (params: GroupViewRequestType) =>
export const useGroupViewQuery = (params: GroupViewRequestType, enabled = true) =>
useQuery<WebuiGroupExtra[], unknown, WebuiGroupExtra[]>({
queryKey: ['webui', 'group-view', params],
queryFn: () => axios.post('WebUI/GroupView', params),
enabled,
});

export const useSeriesFileSummaryQuery = (seriesId: number, params: SeriesFileSummaryRequestType, enabled = true) =>
Expand Down
13 changes: 8 additions & 5 deletions src/pages/collection/Collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,14 @@ function Collection() {

// Couldn't find a way to do it in the query itself like we had in RTKQ, so doing it here
const [groupExtras, setGroupExtras] = useImmer<WebuiGroupExtra[]>([]);
const groupExtrasQuery = useGroupViewQuery({
GroupIDs: lastPageIds,
TagFilter: 128,
TagLimit: 20,
});
const groupExtrasQuery = useGroupViewQuery(
{
GroupIDs: lastPageIds,
TagFilter: 128,
TagLimit: 20,
},
lastPageIds.length > 0,
);

useEffect(() => {
if (!groupExtrasQuery.isSuccess) return;
Expand Down

0 comments on commit 29ff1ea

Please sign in to comment.