Refactor ConnectionState to a shared enum
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user