fix: harden startup flow and auth re-entry
This commit is contained in:
@@ -70,6 +70,7 @@ function App(): React.JSX.Element {
|
||||
const [updateStatus, setUpdateStatus] = useState<UpdateStatus | null>(null)
|
||||
const [updateCatalog, setUpdateCatalog] = useState<UpdateDialogCatalog | null>(null)
|
||||
const [showUpdateDialog, setShowUpdateDialog] = useState(false)
|
||||
const authInitializationStartedRef = React.useRef(false)
|
||||
|
||||
// Load error message from sessionStorage
|
||||
const showError = (message: string) => {
|
||||
@@ -145,6 +146,12 @@ function App(): React.JSX.Element {
|
||||
|
||||
// Initialize authentication on mount
|
||||
useEffect(() => {
|
||||
if (authInitializationStartedRef.current) {
|
||||
logger.debug('Skipping duplicate auth initialization effect')
|
||||
return
|
||||
}
|
||||
|
||||
authInitializationStartedRef.current = true
|
||||
logger.info('=== Initializing auth... ===')
|
||||
void initializeAuth()
|
||||
}, [initializeAuth, logger])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback } from 'react'
|
||||
import { useCallback, useMemo } from 'react'
|
||||
import type { LogLevel } from '../../../shared/ipc-channels'
|
||||
|
||||
/**
|
||||
@@ -70,33 +70,24 @@ export function useLogger(context: string): RendererLogger {
|
||||
)
|
||||
|
||||
// Return memoized logger methods
|
||||
return {
|
||||
log: logger,
|
||||
info: useCallback(
|
||||
(message: string, meta?: Record<string, unknown>) => {
|
||||
return useMemo(
|
||||
() => ({
|
||||
log: logger,
|
||||
info: (message: string, meta?: Record<string, unknown>) => {
|
||||
logger('info', message, meta)
|
||||
},
|
||||
[logger]
|
||||
),
|
||||
warn: useCallback(
|
||||
(message: string, meta?: Record<string, unknown>) => {
|
||||
warn: (message: string, meta?: Record<string, unknown>) => {
|
||||
logger('warn', message, meta)
|
||||
},
|
||||
[logger]
|
||||
),
|
||||
error: useCallback(
|
||||
(message: string, meta?: Record<string, unknown>) => {
|
||||
error: (message: string, meta?: Record<string, unknown>) => {
|
||||
logger('error', message, meta)
|
||||
},
|
||||
[logger]
|
||||
),
|
||||
debug: useCallback(
|
||||
(message: string, meta?: Record<string, unknown>) => {
|
||||
debug: (message: string, meta?: Record<string, unknown>) => {
|
||||
logger('debug', message, meta)
|
||||
},
|
||||
[logger]
|
||||
)
|
||||
}
|
||||
}
|
||||
}),
|
||||
[logger]
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user