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(() => {
|
useEffect(() => {
|
||||||
// Check connection status on initial page load
|
// Check connection status on initial page load
|
||||||
ServerConnections.connect()
|
const apiClient = ServerConnections.currentApiClient();
|
||||||
.then(firstConnection => {
|
const firstConnection = ServerConnections.firstConnection;
|
||||||
console.debug('[ConnectionRequired] connection state', firstConnection?.State);
|
console.debug('[ConnectionRequired] connection state', firstConnection?.State);
|
||||||
|
ServerConnections.firstConnection = null;
|
||||||
|
|
||||||
if (firstConnection && firstConnection.State !== ConnectionState.SignedIn) {
|
if (firstConnection && firstConnection.State !== ConnectionState.SignedIn && !apiClient?.isLoggedIn()) {
|
||||||
return handleIncompleteWizard(firstConnection);
|
handleIncompleteWizard(firstConnection)
|
||||||
} else {
|
|
||||||
return validateUserAccess();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(err => {
|
.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]);
|
}, [handleIncompleteWizard, validateUserAccess]);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ class ServerConnections extends ConnectionManager {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
this.localApiClient = null;
|
this.localApiClient = null;
|
||||||
|
this.firstConnection = null;
|
||||||
|
|
||||||
// Set the apiclient minimum version to match the SDK
|
// Set the apiclient minimum version to match the SDK
|
||||||
this._minServerVersion = MINIMUM_VERSION;
|
this._minServerVersion = MINIMUM_VERSION;
|
||||||
|
|
|
@ -110,6 +110,9 @@ 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();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue