feat: check inboxes immediately on load
This commit is contained in:
1 parent
1d4bc14075
commit
ea72f6697f
1 file changed
+8
-5
+8
-5
@@ -93,10 +93,10 @@ if (env.PUBLIC_MIGRATE_COOKIE && get(profileData).profiles.length == 0 && env.PU
|
|||||||
const jwt = getCookie('jwt')
|
const jwt = getCookie('jwt')
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
new Promise(async () => {
|
new Promise(async () => {
|
||||||
const user = await userFromJwt(jwt, env.PUBLIC_INSTANCE_URL)
|
const user = await userFromJwt(jwt, env.PUBLIC_INSTANCE_URL ?? '')
|
||||||
if (!user) return
|
if (!user) return
|
||||||
|
|
||||||
const result = await setUser(jwt, env.PUBLIC_INSTANCE_URL, user?.user.local_user_view.person.name)
|
const result = await setUser(jwt, env.PUBLIC_INSTANCE_URL ?? '', user?.user.local_user_view.person.name)
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
toast({ content: 'Your instance migrated to Photon, and you were logged in using a leftover cookie.', type: 'success' })
|
toast({ content: 'Your instance migrated to Photon, and you were logged in using a leftover cookie.', type: 'success' })
|
||||||
@@ -373,8 +373,7 @@ const getNotificationCount = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// show unread dot
|
async function checkInboxRepeatedly() {
|
||||||
setInterval(async () => {
|
|
||||||
if (!get(profile)) return
|
if (!get(profile)) return
|
||||||
|
|
||||||
const { user, jwt } = get(profile)!
|
const { user, jwt } = get(profile)!
|
||||||
@@ -396,4 +395,8 @@ setInterval(async () => {
|
|||||||
...p!,
|
...p!,
|
||||||
user: user,
|
user: user,
|
||||||
}))
|
}))
|
||||||
}, 5 * 60 * 1000)
|
|
||||||
|
setTimeout(checkInboxRepeatedly, 5 * 60 * 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
checkInboxRepeatedly()
|
||||||
Reference in new issue
Block a user