WIP history and such not quite working (404ing)

This commit is contained in:
Chuck Dries 2023-03-07 23:48:49 -08:00
parent 5aae745c04
commit 80169f1803

View File

@ -41,9 +41,11 @@ function smartCompareDates(
return compareDates(SORT_KEYS.date, left, right); return compareDates(SORT_KEYS.date, left, right);
} }
const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => { const GalleryPage = ({ data, location }: PageProps<Queries.GalleryPageQueryQuery>) => {
const hash = // const hash =
typeof window !== "undefined" ? window.location.hash.replace("#", "") : ""; // typeof window !== "undefined" ? window.location.hash.replace("#", "") : "";
const hash = location.hash ? location.hash.replace("#", "") : "";
const [hashCleared, setHashCleared] = React.useState(false); // eslint-disable-line no-unused-vars const [hashCleared, setHashCleared] = React.useState(false); // eslint-disable-line no-unused-vars
// ^ used just to force a re-render with the cleared hash value (I know, it's a smell for sure) // ^ used just to force a re-render with the cleared hash value (I know, it's a smell for sure)
@ -141,7 +143,7 @@ const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => {
// don't scroll into view if user got here with back button // don't scroll into view if user got here with back button
scrollIntoView(); scrollIntoView();
}, 100); }, 100);
}, [setSortKey, setKeyword, scrollIntoView]); }, [setSortKey, setKeyword, scrollIntoView, location]);
const images: GalleryImage[] = React.useMemo(() => { const images: GalleryImage[] = React.useMemo(() => {
const sort = const sort =