From 61839e66c8e82ab6c1d26b80553592376f6f5e18 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Thu, 25 Apr 2024 23:02:55 -0500 Subject: [PATCH] Improve swr promise handling --- src/admin/AdminPhotoMenuClient.tsx | 4 +--- src/photo/InfinitePhotoScroll.tsx | 10 ++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/admin/AdminPhotoMenuClient.tsx b/src/admin/AdminPhotoMenuClient.tsx index b3b8f318..049a52a8 100644 --- a/src/admin/AdminPhotoMenuClient.tsx +++ b/src/admin/AdminPhotoMenuClient.tsx @@ -62,9 +62,7 @@ export default function AdminPhotoMenuClient({ photo.id, photo.url, shouldRedirectDelete, - ).then(() => { - revalidatePhoto?.(true); - }); + ).then(() => revalidatePhoto?.(true)); } }, }, diff --git a/src/photo/InfinitePhotoScroll.tsx b/src/photo/InfinitePhotoScroll.tsx index 81a9c6e6..eebac66a 100644 --- a/src/photo/InfinitePhotoScroll.tsx +++ b/src/photo/InfinitePhotoScroll.tsx @@ -10,7 +10,9 @@ import { getPhotosAction } from '@/photo/actions'; import { useAppState } from '@/state/AppState'; import { Photo } from '.'; -export type RevalidatePhotos = (revalidateRemainingPhotos?: boolean) => void; +export type RevalidatePhotos = ( + revalidateRemainingPhotos?: boolean, +) => Promise; export default function InfinitePhotoScroll({ key = 'PHOTOS', @@ -85,12 +87,12 @@ export default function InfinitePhotoScroll({ { + revalidatePhotos={(revalidateRemainingPhotos?: boolean) => mutate(data, { revalidate: (_data: any, [_, size]:[string, number]) => revalidateRemainingPhotos ? size >= i : size === i, - } as any); - }} + } as any) + } />)} } {!isFinished &&