From dcc90e3e2f31a91343651faa17d58e71328e33de Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Tue, 16 Apr 2024 02:49:57 +0200 Subject: [PATCH] Do not emit storage event when changing grid snapshot To prevent unnecessary re-renders. The current grid state was stored in the session storage which then triggered an immediate re-render because the just saved snapshot got restored again --- src/components/MangaGrid.tsx | 2 +- src/screens/SourceMangas.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MangaGrid.tsx b/src/components/MangaGrid.tsx index d43acb8d..cce67042 100644 --- a/src/components/MangaGrid.tsx +++ b/src/components/MangaGrid.tsx @@ -165,7 +165,7 @@ const VerticalGrid = forwardRef( return; } - AppStorage.session.setItem(snapshotSessionKey, gridState); + AppStorage.session.setItem(snapshotSessionKey, gridState, false); }, 250); }; useEffect(() => clearTimeout(persistGridStateTimeout.current), [location.key, persistGridStateTimeout.current]); diff --git a/src/screens/SourceMangas.tsx b/src/screens/SourceMangas.tsx index e83c8c13..9c226bb4 100644 --- a/src/screens/SourceMangas.tsx +++ b/src/screens/SourceMangas.tsx @@ -269,7 +269,7 @@ export function SourceMangas() { ); const scrollToTop = useCallback(() => { - AppStorage.session.setItem(getGridSnapshotKey(location), undefined); + AppStorage.session.setItem(getGridSnapshotKey(location), undefined, false); window.scrollTo(0, 0); }, [locationKey]);