mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Refactor ConnectionState to a shared enum
This commit is contained in:
parent
f3dda2e783
commit
7e9bf96668
6 changed files with 39 additions and 25 deletions
|
@ -9,6 +9,7 @@ import loading from './loading/loading';
|
|||
import viewManager from './viewManager/viewManager';
|
||||
import ServerConnections from './ServerConnections';
|
||||
import alert from './alert';
|
||||
import { ConnectionState } from '../utils/jellyfin-apiclient/ConnectionState.ts';
|
||||
|
||||
export const history = createHashHistory();
|
||||
|
||||
|
@ -201,17 +202,17 @@ class AppRouter {
|
|||
|
||||
#handleConnectionResult(result) {
|
||||
switch (result.State) {
|
||||
case 'SignedIn':
|
||||
case ConnectionState.SignedIn:
|
||||
loading.hide();
|
||||
this.goHome();
|
||||
break;
|
||||
case 'ServerSignIn':
|
||||
case ConnectionState.ServerSignIn:
|
||||
this.showLocalLogin(result.ApiClient.serverId());
|
||||
break;
|
||||
case 'ServerSelection':
|
||||
case ConnectionState.ServerSelection:
|
||||
this.showSelectServer();
|
||||
break;
|
||||
case 'ServerUpdateNeeded':
|
||||
case ConnectionState.ServerUpdateNeeded:
|
||||
alert({
|
||||
text: globalize.translate('ServerUpdateNeeded', 'https://github.com/jellyfin/jellyfin'),
|
||||
html: globalize.translate('ServerUpdateNeeded', '<a href="https://github.com/jellyfin/jellyfin">https://github.com/jellyfin/jellyfin</a>')
|
||||
|
@ -365,7 +366,7 @@ class AppRouter {
|
|||
|
||||
this.firstConnectionResult = null;
|
||||
if (firstResult) {
|
||||
if (firstResult.State === 'ServerSignIn') {
|
||||
if (firstResult.State === ConnectionState.ServerSignIn) {
|
||||
const url = firstResult.ApiClient.serverAddress() + '/System/Info/Public';
|
||||
fetch(url).then(response => {
|
||||
if (!response.ok) return Promise.reject('fetch failed');
|
||||
|
@ -382,7 +383,7 @@ class AppRouter {
|
|||
});
|
||||
|
||||
return;
|
||||
} else if (firstResult.State !== 'SignedIn') {
|
||||
} else if (firstResult.State !== ConnectionState.SignedIn) {
|
||||
this.#handleConnectionResult(firstResult);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue