mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2024-12-23 07:26:36 +01:00
refs #4653 Save the last account and go to there when opened
This commit is contained in:
parent
293c680b1c
commit
189996a34a
@ -14,7 +14,9 @@ export default function Page() {
|
||||
|
||||
useEffect(() => {
|
||||
if (router.query.id) {
|
||||
console.log(router)
|
||||
if (router.query.id && typeof localStorage !== 'undefined') {
|
||||
localStorage.setItem('lastAccount', router.query.id as string)
|
||||
}
|
||||
const f = async () => {
|
||||
const a = await db.accounts.get(parseInt(router.query.id as string))
|
||||
if (a) {
|
||||
|
@ -11,8 +11,17 @@ export default function Index() {
|
||||
const f = async () => {
|
||||
const accounts = await db.accounts.toArray()
|
||||
if (accounts.length > 0) {
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
const lastAccount = localStorage.getItem(`lastAccount`)
|
||||
if (lastAccount) {
|
||||
router.push(`/accounts/${lastAccount}`)
|
||||
} else {
|
||||
router.push(`/accounts/${accounts[0].id}`)
|
||||
}
|
||||
} else {
|
||||
router.push(`/accounts/${accounts[0].id}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
f()
|
||||
}, [])
|
||||
|
Loading…
Reference in New Issue
Block a user