fix loading
This commit is contained in:
@@ -14,6 +14,7 @@ import { showLoading, hideLoading } from './components/loading'
|
|||||||
const app = document.getElementById('app')!
|
const app = document.getElementById('app')!
|
||||||
|
|
||||||
let currentHandle = ''
|
let currentHandle = ''
|
||||||
|
let isFirstRender = true
|
||||||
|
|
||||||
// Filter collections by service domain
|
// Filter collections by service domain
|
||||||
function filterCollectionsByService(collections: string[], service: string): string[] {
|
function filterCollectionsByService(collections: string[], service: string): string[] {
|
||||||
@@ -52,7 +53,10 @@ async function getWebUrl(handle: string): Promise<string | undefined> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function render(route: Route): Promise<void> {
|
async function render(route: Route): Promise<void> {
|
||||||
showLoading(app)
|
// Skip loading indicator on first render for faster perceived performance
|
||||||
|
if (!isFirstRender) {
|
||||||
|
showLoading(app)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const config = await getConfig()
|
const config = await getConfig()
|
||||||
@@ -73,12 +77,14 @@ async function render(route: Route): Promise<void> {
|
|||||||
// Handle OAuth callback if present (check both ? and #)
|
// Handle OAuth callback if present (check both ? and #)
|
||||||
const searchParams = new URLSearchParams(window.location.search)
|
const searchParams = new URLSearchParams(window.location.search)
|
||||||
const hashParams = window.location.hash ? new URLSearchParams(window.location.hash.slice(1)) : null
|
const hashParams = window.location.hash ? new URLSearchParams(window.location.hash.slice(1)) : null
|
||||||
if (searchParams.has('code') || searchParams.has('state') || hashParams?.has('code') || hashParams?.has('state')) {
|
if (oauthEnabled && (searchParams.has('code') || searchParams.has('state') || hashParams?.has('code') || hashParams?.has('state'))) {
|
||||||
await handleCallback()
|
await handleCallback()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore session from storage
|
// Restore session from storage (skip if oauth disabled)
|
||||||
await restoreSession()
|
if (oauthEnabled) {
|
||||||
|
await restoreSession()
|
||||||
|
}
|
||||||
|
|
||||||
// Redirect logged-in user from root to their user page
|
// Redirect logged-in user from root to their user page
|
||||||
if (route.type === 'home' && isLoggedIn()) {
|
if (route.type === 'home' && isLoggedIn()) {
|
||||||
@@ -273,6 +279,8 @@ async function render(route: Route): Promise<void> {
|
|||||||
`
|
`
|
||||||
hideLoading(app)
|
hideLoading(app)
|
||||||
setupEventHandlers()
|
setupEventHandlers()
|
||||||
|
} finally {
|
||||||
|
isFirstRender = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user