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