From 6362e00a71665074b698c91217929ead71762e9f Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 7 Mar 2023 10:36:39 +0800 Subject: [PATCH] Stash the current filter so when we pop we can return to it --- .../templates/homeFeed/HomeFeedContainer.tsx | 1 + packages/web/pages/[username]/[slug]/index.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index 316c028a1..51312be3b 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -541,6 +541,7 @@ export function HomeFeedContainer(): JSX.Element { } const href = `${window.location.pathname}?${qp.toString()}` router.push(href, href, { shallow: true }) + window.sessionStorage.setItem('q', qp.toString()) performActionOnItem('refresh', undefined as unknown as any) }} loadMore={() => { diff --git a/packages/web/pages/[username]/[slug]/index.tsx b/packages/web/pages/[username]/[slug]/index.tsx index be8a289f8..1a071ee4d 100644 --- a/packages/web/pages/[username]/[slug]/index.tsx +++ b/packages/web/pages/[username]/[slug]/index.tsx @@ -208,7 +208,15 @@ export default function Home(): JSX.Element { section: 'Article', name: 'Return to library', shortcut: ['u'], - perform: () => router.push(`/home`), + perform: () => { + const query = window.sessionStorage.getItem('q') + if (query) { + router.push(`/home?${query}`) + return + } else { + router.push(`/home`) + } + }, }, { id: 'archive',