mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Only connect to ServerConnections once (#6150)
* Only connect to ServerConnections once * Fix initial login after wizard completion * Fix login when refreshing login or select server page
This commit is contained in:
parent
176ebec6e2
commit
230925e159
3 changed files with 19 additions and 12 deletions
|
@ -149,19 +149,22 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
|||
|
||||
useEffect(() => {
|
||||
// Check connection status on initial page load
|
||||
ServerConnections.connect()
|
||||
.then(firstConnection => {
|
||||
const apiClient = ServerConnections.currentApiClient();
|
||||
const firstConnection = ServerConnections.firstConnection;
|
||||
console.debug('[ConnectionRequired] connection state', firstConnection?.State);
|
||||
ServerConnections.firstConnection = null;
|
||||
|
||||
if (firstConnection && firstConnection.State !== ConnectionState.SignedIn) {
|
||||
return handleIncompleteWizard(firstConnection);
|
||||
} else {
|
||||
return validateUserAccess();
|
||||
}
|
||||
})
|
||||
if (firstConnection && firstConnection.State !== ConnectionState.SignedIn && !apiClient?.isLoggedIn()) {
|
||||
handleIncompleteWizard(firstConnection)
|
||||
.catch(err => {
|
||||
console.error('[ConnectionRequired] failed to connect to server', err);
|
||||
console.error('[ConnectionRequired] could not start wizard', err);
|
||||
});
|
||||
} else {
|
||||
validateUserAccess()
|
||||
.catch(err => {
|
||||
console.error('[ConnectionRequired] could not validate user access', err);
|
||||
});
|
||||
}
|
||||
}, [handleIncompleteWizard, validateUserAccess]);
|
||||
|
||||
if (isLoading) {
|
||||
|
|
|
@ -33,6 +33,7 @@ class ServerConnections extends ConnectionManager {
|
|||
constructor() {
|
||||
super(...arguments);
|
||||
this.localApiClient = null;
|
||||
this.firstConnection = null;
|
||||
|
||||
// Set the apiclient minimum version to match the SDK
|
||||
this._minServerVersion = MINIMUM_VERSION;
|
||||
|
|
|
@ -110,6 +110,9 @@ build: ${__JF_BUILD_VERSION__}`);
|
|||
Events.on(apiClient, 'requestfail', appRouter.onRequestFail);
|
||||
});
|
||||
|
||||
// Connect to server
|
||||
ServerConnections.firstConnection = await ServerConnections.connect();
|
||||
|
||||
// Render the app
|
||||
await renderApp();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue