Revert swr strategy
This commit is contained in:
parent
ff5e079c27
commit
242380811b
@ -51,7 +51,7 @@
|
||||
"react-dom": "18.2.0",
|
||||
"react-icons": "^5.1.0",
|
||||
"sonner": "^1.4.41",
|
||||
"swr": "^2.2.6-beta.1",
|
||||
"swr": "^2.2.5",
|
||||
"tailwindcss": "3.4.3",
|
||||
"ts-exif-parser": "^0.2.2",
|
||||
"typescript": "5.4.5",
|
||||
|
||||
11
pnpm-lock.yaml
generated
11
pnpm-lock.yaml
generated
@ -135,8 +135,8 @@ importers:
|
||||
specifier: ^1.4.41
|
||||
version: 1.4.41(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
|
||||
swr:
|
||||
specifier: ^2.2.6-beta.1
|
||||
version: 2.2.6-beta.1(react@18.2.0)
|
||||
specifier: ^2.2.5
|
||||
version: 2.2.5(react@18.2.0)
|
||||
tailwindcss:
|
||||
specifier: 3.4.3
|
||||
version: 3.4.3
|
||||
@ -3773,8 +3773,8 @@ packages:
|
||||
peerDependencies:
|
||||
react: ^16.11.0 || ^17.0.0 || ^18.0.0
|
||||
|
||||
swr@2.2.6-beta.1:
|
||||
resolution: {integrity: sha512-YqC6vjeuHoGnx2JSMK/sophBhqO7+oQPNRM9kHWZ0mpb3RtyeqTmRr5osBywZHd24muvLziroPjYY60h/nuohw==}
|
||||
swr@2.2.5:
|
||||
resolution: {integrity: sha512-QtxqyclFeAsxEUeZIYmsaQ0UjimSq1RZ9Un7I68/0ClKK/U3LoyQunwkQfJZr2fc22DfIXLNDc2wFyTEikCUpg==}
|
||||
peerDependencies:
|
||||
react: ^16.11.0 || ^17.0.0 || ^18.0.0
|
||||
|
||||
@ -8741,8 +8741,9 @@ snapshots:
|
||||
react: 18.2.0
|
||||
use-sync-external-store: 1.2.0(react@18.2.0)
|
||||
|
||||
swr@2.2.6-beta.1(react@18.2.0):
|
||||
swr@2.2.5(react@18.2.0):
|
||||
dependencies:
|
||||
client-only: 0.0.1
|
||||
react: 18.2.0
|
||||
use-sync-external-store: 1.2.0(react@18.2.0)
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import { usePathname } from 'next/navigation';
|
||||
import { BiTrash } from 'react-icons/bi';
|
||||
import MoreMenu from '@/components/MoreMenu';
|
||||
import { useAppState } from '@/state/AppState';
|
||||
import { useSWRConfig } from 'swr';
|
||||
|
||||
export default function AdminPhotoMenuClient({
|
||||
photo,
|
||||
@ -25,8 +24,6 @@ export default function AdminPhotoMenuClient({
|
||||
const shouldRedirectFav = isPathFavs(path) && isFav;
|
||||
const shouldRedirectDelete = pathForPhoto(photo.id) === path;
|
||||
|
||||
const { mutate } = useSWRConfig();
|
||||
|
||||
return (
|
||||
isUserSignedIn
|
||||
? <MoreMenu {...{
|
||||
@ -49,9 +46,7 @@ export default function AdminPhotoMenuClient({
|
||||
action: () => toggleFavoritePhotoAction(
|
||||
photo.id,
|
||||
shouldRedirectFav,
|
||||
).then(() => {
|
||||
if (photo.cacheKey) { mutate(photo.cacheKey); }
|
||||
}),
|
||||
),
|
||||
}, {
|
||||
label: 'Delete',
|
||||
icon: <BiTrash
|
||||
|
||||
@ -7,6 +7,7 @@ import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
||||
import { Metadata } from 'next/types';
|
||||
import { MAX_PHOTOS_TO_SHOW_OG } from '@/image-response';
|
||||
import InfinitePhotoScroll from '../photo/InfinitePhotoScroll';
|
||||
import PhotosLarge from '@/photo/PhotosLarge';
|
||||
|
||||
export const dynamic = 'force-static';
|
||||
|
||||
@ -29,8 +30,9 @@ export default async function HomePage() {
|
||||
return (
|
||||
photos.length > 0
|
||||
? <div className="space-y-1">
|
||||
<PhotosLarge {...{ photos }} />
|
||||
<InfinitePhotoScroll
|
||||
initialPhotos={photos}
|
||||
initialOffset={INFINITE_SCROLL_MULTIPLE_HOME}
|
||||
itemsPerPage={INFINITE_SCROLL_MULTIPLE_HOME}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -8,10 +8,8 @@ import SiteGrid from '@/components/SiteGrid';
|
||||
import Spinner from '@/components/Spinner';
|
||||
import { getPhotosAction } from '@/photo/actions';
|
||||
import { useAppState } from '@/state/AppState';
|
||||
import { Photo } from '.';
|
||||
|
||||
export default function InfinitePhotoScroll({
|
||||
initialPhotos,
|
||||
key = 'PHOTOS',
|
||||
initialOffset = 0,
|
||||
itemsPerPage = 12,
|
||||
@ -19,7 +17,6 @@ export default function InfinitePhotoScroll({
|
||||
triggerOnView = true,
|
||||
debug = true,
|
||||
}: {
|
||||
initialPhotos?: Photo[]
|
||||
key?: string
|
||||
initialOffset?: number
|
||||
itemsPerPage?: number
|
||||
@ -50,7 +47,6 @@ export default function InfinitePhotoScroll({
|
||||
revalidateOnFocus: isUserSignedIn,
|
||||
revalidateOnReconnect: isUserSignedIn,
|
||||
revalidateFirstPage: isUserSignedIn,
|
||||
...initialPhotos && { fallbackData: [initialPhotos] },
|
||||
},
|
||||
);
|
||||
|
||||
@ -88,20 +84,21 @@ export default function InfinitePhotoScroll({
|
||||
<div className="space-y-4">
|
||||
{photos && <PhotosLarge photos={photos} />}
|
||||
{!isFinished &&
|
||||
<SiteGrid contentMain={
|
||||
<button
|
||||
ref={buttonRef}
|
||||
onClick={error ? () => mutate() : advance}
|
||||
disabled={isLoading}
|
||||
className="w-full flex justify-center"
|
||||
>
|
||||
{error
|
||||
? 'Try Again'
|
||||
: isLoading
|
||||
? <Spinner size={20} />
|
||||
: 'Load More'}
|
||||
</button>
|
||||
} />}
|
||||
<SiteGrid
|
||||
contentMain={
|
||||
<button
|
||||
ref={buttonRef}
|
||||
onClick={error ? () => mutate() : advance}
|
||||
disabled={isLoading}
|
||||
className="w-full flex justify-center"
|
||||
>
|
||||
{error
|
||||
? 'Try Again'
|
||||
: isLoading
|
||||
? <Spinner size={20} />
|
||||
: 'Load More'}
|
||||
</button>
|
||||
} />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user