From 81b0d797b74a41ff4432733dfcb10724a434566b Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Mon, 1 Apr 2024 10:25:40 -0500 Subject: [PATCH] Fix admin nav count count after upload --- src/app/admin/photos/page.tsx | 10 +++++++++- src/photo/PhotoUpload.tsx | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/app/admin/photos/page.tsx b/src/app/admin/photos/page.tsx index cb8f78bf..cb107ff7 100644 --- a/src/app/admin/photos/page.tsx +++ b/src/app/admin/photos/page.tsx @@ -34,6 +34,7 @@ import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus'; import IconGrSync from '@/site/IconGrSync'; import { getStoragePhotoUrlsNoStore } from '@/services/storage/cache'; import PhotoDate from '@/photo/PhotoDate'; +import { revalidatePath } from 'next/cache'; const DEBUG_PHOTO_BLOBS = false; @@ -58,7 +59,14 @@ export default async function AdminPhotosPage({ - + { + 'use server'; + // Update upload count in admin nav + revalidatePath('/admin', 'layout'); + }} + /> {blobPhotoUrls.length > 0 &&
Promise debug?: boolean }) { const [isUploading, setIsUploading] = useState(false); @@ -55,11 +57,9 @@ export default function PhotoUpload({ blob, extension, ) - .then(url => { + .then(async url => { if (isLastBlob) { - // Refresh page to update upload list, - // relevant to upload count in nav - router.refresh(); + await onLastUpload?.(); if (hasMultipleUploads) { // Redirect to view multiple uploads router.push(PATH_ADMIN_UPLOADS);