Skip to content

Commit

Permalink
preserve last opened page
Browse files Browse the repository at this point in the history
  • Loading branch information
quinn committed Jan 28, 2024
1 parent 3d60b12 commit 0080f76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/components/pages/AccountsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { formatMoney } from './ChartPage'

export function AccountsPage() {
const { data, refetch } = trpc.institutions.useQuery()
console.log({ PlaidLinkButton })

return (
<div className="overflow-y-auto">
Expand Down
10 changes: 10 additions & 0 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { Page } from './lib/types'
import { AccountsPage } from './components/pages/AccountsPage'
import { SettingsPage } from './components/pages/SettingsPage'

const LastRouteKey = 'lastRoute' as const
const lastRoute = localStorage.getItem(LastRouteKey)

export const router = createMemoryRouter(
createRoutesFromElements(
<Route path="/" element={<Root />}>
Expand All @@ -21,4 +24,11 @@ export const router = createMemoryRouter(
<Route path={Page.SETTINGS} element={<SettingsPage />} />
</Route>,
),
{
initialEntries: lastRoute ? [lastRoute] : undefined,
},
)

router.subscribe((route) => {
localStorage.setItem(LastRouteKey, route.location.pathname)
})

0 comments on commit 0080f76

Please sign in to comment.