Always fetch fresh data for admin menu
This commit is contained in:
parent
0849450210
commit
de5f49261b
@ -7,8 +7,8 @@ import { testDatabaseConnection } from '@/platforms/postgres';
|
||||
import { testStorageConnection } from '@/platforms/storage';
|
||||
import { APP_CONFIGURATION } from '@/app/config';
|
||||
import { getStorageUploadUrlsNoStore } from '@/platforms/storage/cache';
|
||||
import { getPhotosMetaCached, getUniqueTagsCached } from '@/photo/cache';
|
||||
import { getInsightsIndicatorStatus } from '@/admin/insights/server';
|
||||
import { getPhotosMeta, getUniqueTags } from '@/photo/db/query';
|
||||
|
||||
export type AdminData = Awaited<ReturnType<typeof getAdminDataAction>>;
|
||||
|
||||
@ -21,13 +21,13 @@ export const getAdminDataAction = async () =>
|
||||
uploadsCount,
|
||||
insightsIndicatorStatus,
|
||||
] = await Promise.all([
|
||||
getPhotosMetaCached()
|
||||
getPhotosMeta()
|
||||
.then(({ count }) => count)
|
||||
.catch(() => 0),
|
||||
getPhotosMetaCached({ hidden: 'only' })
|
||||
getPhotosMeta({ hidden: 'only' })
|
||||
.then(({ count }) => count)
|
||||
.catch(() => 0),
|
||||
getUniqueTagsCached()
|
||||
getUniqueTags()
|
||||
.then(tags => tags.length)
|
||||
.catch(() => 0),
|
||||
getStorageUploadUrlsNoStore()
|
||||
|
||||
@ -106,9 +106,7 @@ export default function AppStateProvider({
|
||||
|
||||
const { data: adminData, mutate: refreshAdminData } = useSWR(
|
||||
isUserSignedIn ? 'getAdminData' : null,
|
||||
getAdminDataAction, {
|
||||
refreshInterval: 1000 * 60,
|
||||
},
|
||||
getAdminDataAction,
|
||||
);
|
||||
const updateAdminData = useCallback(
|
||||
(updatedData: Partial<AdminData>) => {
|
||||
@ -124,7 +122,7 @@ export default function AppStateProvider({
|
||||
if (userEmail) {
|
||||
storeAuthEmailCookie(userEmail);
|
||||
}
|
||||
}, [userEmail, refreshAdminData, adminData]);
|
||||
}, [userEmail, adminData]);
|
||||
|
||||
const registerAdminUpdate = useCallback(() =>
|
||||
setAdminUpdateTimes(updates => [...updates, new Date()])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user