1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix async route page refresh

This commit is contained in:
viown 2024-12-15 14:01:12 +03:00
parent d56ff77308
commit 206f70cf34
2 changed files with 18 additions and 17 deletions

View file

@ -150,21 +150,25 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
useEffect(() => { useEffect(() => {
// Check connection status on initial page load // Check connection status on initial page load
const apiClient = ServerConnections.currentApiClient(); const apiClient = ServerConnections.currentApiClient();
const firstConnection = ServerConnections.firstConnection; const connection = Promise.resolve(ServerConnections.firstConnection ? null : ServerConnections.connect());
console.debug('[ConnectionRequired] connection state', firstConnection?.State); connection.then(firstConnection => {
ServerConnections.firstConnection = null; console.debug('[ConnectionRequired] connection state', firstConnection?.State);
ServerConnections.firstConnection = true;
if (firstConnection && firstConnection.State !== ConnectionState.SignedIn && !apiClient?.isLoggedIn()) { if (firstConnection && firstConnection.State !== ConnectionState.SignedIn && !apiClient?.isLoggedIn()) {
handleIncompleteWizard(firstConnection) handleIncompleteWizard(firstConnection)
.catch(err => { .catch(err => {
console.error('[ConnectionRequired] could not start wizard', err); console.error('[ConnectionRequired] could not start wizard', err);
}); });
} else { } else {
validateUserAccess() validateUserAccess()
.catch(err => { .catch(err => {
console.error('[ConnectionRequired] could not validate user access', err); console.error('[ConnectionRequired] could not validate user access', err);
}); });
} }
}).catch(err => {
console.error('[ConnectionRequired] failed to connect', err);
});
}, [handleIncompleteWizard, validateUserAccess]); }, [handleIncompleteWizard, validateUserAccess]);
if (isLoading) { if (isLoading) {

View file

@ -110,9 +110,6 @@ build: ${__JF_BUILD_VERSION__}`);
Events.on(apiClient, 'requestfail', appRouter.onRequestFail); Events.on(apiClient, 'requestfail', appRouter.onRequestFail);
}); });
// Connect to server
ServerConnections.firstConnection = await ServerConnections.connect();
// Render the app // Render the app
await renderApp(); await renderApp();