pl-fe: do not fetch reports count before fetching instance, but this time fr

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-08-02 14:13:03 +02:00
parent 8aa61a6d0e
commit 90c36c8ead
2 changed files with 5 additions and 5 deletions

View File

@ -39,7 +39,7 @@ const usePendingReportsCount = () => {
return useInfiniteQuery({
...pendingReportsQuery,
select: (data) => data.pages.at(-1)?.total || data.pages.map(page => page.items).flat().length || 0,
enabled: !!instance.domain && (account?.is_admin || account?.is_moderator),
enabled: !!instance.fetched && (account?.is_admin || account?.is_moderator),
});
};

View File

@ -8,9 +8,9 @@ import { PLEROMA_PRELOAD_IMPORT, type PreloadAction } from 'pl-fe/actions/preloa
import KVStore from 'pl-fe/storage/kv-store';
import ConfigDB from 'pl-fe/utils/config-db';
const initialState: State = v.parse(instanceSchema, {});
const initialState: State = { fetched: false, ...v.parse(instanceSchema, {}) };
type State = Instance;
type State = Instance & { fetched : boolean };
const preloadImport = (state: State, action: Record<string, any>, path: string) => {
const instance = action.data[path];
@ -87,10 +87,10 @@ const handleInstanceFetchFail = (state: State, error: any) => {
const instance = (state = initialState, action: AdminActions | InstanceAction | PreloadAction): State => {
switch (action.type) {
case PLEROMA_PRELOAD_IMPORT:
return create(state, (draft) => preloadImport(draft, action, '/api/v1/instance'));
return create(state, (draft) => ({ fetched: true, ...preloadImport(draft, action, '/api/v1/instance') }));
case INSTANCE_FETCH_SUCCESS:
persistInstance(action.instance);
return action.instance;
return { fetched: true, ...action.instance };
case INSTANCE_FETCH_FAIL:
return handleInstanceFetchFail(state, action.error);
case ADMIN_CONFIG_UPDATE_REQUEST: