feat: render app shell with ssr to improve loading experience (#448)

This commit is contained in:
Daniel Roe 2022-12-17 16:55:29 +00:00 committed by GitHub
parent b545efeacc
commit 9395b7031e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 169 additions and 127 deletions

View file

@ -73,8 +73,6 @@ export async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: Ac
}
}
setMasto(masto)
if ('server' in route.params && user?.token) {
await router.push({
...route,
@ -117,6 +115,7 @@ const notifications = reactive<Record<string, undefined | [Promise<WsEvents>, nu
export const useNotifications = () => {
const id = currentUser.value?.account.id
const masto = useMasto()
const clearNotifications = () => {
if (!id || !notifications[id])
@ -125,10 +124,9 @@ export const useNotifications = () => {
}
async function connect(): Promise<void> {
if (!id || notifications[id] || !currentUser.value?.token)
if (!isMastoInitialised.value || !id || notifications[id] || !currentUser.value?.token)
return
const masto = useMasto()
const stream = masto.stream.streamUser()
notifications[id] = [stream, 0]
;(await stream).on('notification', () => {