Refactor batch id clearing
This commit is contained in:
parent
4d2cb31819
commit
730708b0db
@ -15,7 +15,7 @@ import { IoArrowDown, IoArrowUp, IoCloseSharp } from 'react-icons/io5';
|
|||||||
import { clsx } from 'clsx/lite';
|
import { clsx } from 'clsx/lite';
|
||||||
import AdminAppInfoIcon from './AdminAppInfoIcon';
|
import AdminAppInfoIcon from './AdminAppInfoIcon';
|
||||||
import { signOutAction } from '@/auth/actions';
|
import { signOutAction } from '@/auth/actions';
|
||||||
import { ComponentProps, useMemo } from 'react';
|
import { ComponentProps, useEffect, useMemo } from 'react';
|
||||||
import useIsKeyBeingPressed from '@/utility/useIsKeyBeingPressed';
|
import useIsKeyBeingPressed from '@/utility/useIsKeyBeingPressed';
|
||||||
import IconPhoto from '@/components/icons/IconPhoto';
|
import IconPhoto from '@/components/icons/IconPhoto';
|
||||||
import IconUpload from '@/components/icons/IconUpload';
|
import IconUpload from '@/components/icons/IconUpload';
|
||||||
@ -56,6 +56,15 @@ export default function AdminAppMenu({
|
|||||||
clearAuthStateAndRedirectIfNecessary,
|
clearAuthStateAndRedirectIfNecessary,
|
||||||
} = useAppState();
|
} = useAppState();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
pathname !== PATH_GRID_INFERRED &&
|
||||||
|
selectedPhotoIds !== undefined
|
||||||
|
) {
|
||||||
|
setSelectedPhotoIds?.(undefined);
|
||||||
|
}
|
||||||
|
}, [pathname, selectedPhotoIds, setSelectedPhotoIds]);
|
||||||
|
|
||||||
const appText = useAppText();
|
const appText = useAppText();
|
||||||
|
|
||||||
const isSelecting = selectedPhotoIds !== undefined;
|
const isSelecting = selectedPhotoIds !== undefined;
|
||||||
@ -162,13 +171,11 @@ export default function AdminAppMenu({
|
|||||||
href: PATH_GRID_INFERRED,
|
href: PATH_GRID_INFERRED,
|
||||||
},
|
},
|
||||||
action: () => {
|
action: () => {
|
||||||
setTimeout(() => {
|
|
||||||
if (isSelecting) {
|
if (isSelecting) {
|
||||||
setSelectedPhotoIds?.(undefined);
|
setSelectedPhotoIds?.(undefined);
|
||||||
} else {
|
} else {
|
||||||
setSelectedPhotoIds?.([]);
|
setSelectedPhotoIds?.([]);
|
||||||
}
|
}
|
||||||
}, 200);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,7 @@ import { Photo } from '.';
|
|||||||
import { PATH_GRID_INFERRED } from '@/app/path';
|
import { PATH_GRID_INFERRED } from '@/app/path';
|
||||||
import PhotoGridSidebar from './PhotoGridSidebar';
|
import PhotoGridSidebar from './PhotoGridSidebar';
|
||||||
import PhotoGridContainer from './PhotoGridContainer';
|
import PhotoGridContainer from './PhotoGridContainer';
|
||||||
import { ComponentProps, useEffect, useMemo, useRef } from 'react';
|
import { ComponentProps, useMemo, useRef } from 'react';
|
||||||
import { useAppState } from '@/app/AppState';
|
|
||||||
import clsx from 'clsx/lite';
|
import clsx from 'clsx/lite';
|
||||||
import MaskedScroll from '@/components/MaskedScroll';
|
import MaskedScroll from '@/components/MaskedScroll';
|
||||||
import { IS_RECENTS_FIRST } from '@/app/config';
|
import { IS_RECENTS_FIRST } from '@/app/config';
|
||||||
@ -28,13 +27,6 @@ export default function PhotoGridPageClient({
|
|||||||
}) {
|
}) {
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { setSelectedPhotoIds } = useAppState();
|
|
||||||
|
|
||||||
useEffect(
|
|
||||||
() => () => setSelectedPhotoIds?.(undefined),
|
|
||||||
[setSelectedPhotoIds],
|
|
||||||
);
|
|
||||||
|
|
||||||
const viewPortHeight = useViewportHeight();
|
const viewPortHeight = useViewportHeight();
|
||||||
const containerHeight = useMemo(() =>
|
const containerHeight = useMemo(() =>
|
||||||
viewPortHeight - (ref.current?.getBoundingClientRect().y ?? 0),
|
viewPortHeight - (ref.current?.getBoundingClientRect().y ?? 0),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user