Improve swr promise handling

This commit is contained in:
Sam Becker 2024-04-25 23:02:55 -05:00
parent 4fa85316e8
commit 61839e66c8
2 changed files with 7 additions and 7 deletions

View File

@ -62,9 +62,7 @@ export default function AdminPhotoMenuClient({
photo.id,
photo.url,
shouldRedirectDelete,
).then(() => {
revalidatePhoto?.(true);
});
).then(() => revalidatePhoto?.(true));
}
},
},

View File

@ -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<any>;
export default function InfinitePhotoScroll({
key = 'PHOTOS',
@ -85,12 +87,12 @@ export default function InfinitePhotoScroll({
<PhotosLarge
key={i}
photos={photos}
revalidatePhotos={(revalidateRemainingPhotos?: boolean) => {
revalidatePhotos={(revalidateRemainingPhotos?: boolean) =>
mutate(data, {
revalidate: (_data: any, [_, size]:[string, number]) =>
revalidateRemainingPhotos ? size >= i : size === i,
} as any);
}}
} as any)
}
/>)}
</div>}
{!isFinished &&