mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #4083 from thornbill/connection-state-refactor
Refactor ConnectionState to a shared enum
This commit is contained in:
commit
feb35ede21
6 changed files with 39 additions and 25 deletions
|
@ -1,11 +1,13 @@
|
|||
import React, { FunctionComponent, useEffect, useState } from 'react';
|
||||
import { Outlet, useNavigate } from 'react-router-dom';
|
||||
import type { ConnectResponse } from 'jellyfin-apiclient';
|
||||
|
||||
import alert from './alert';
|
||||
import { appRouter } from './appRouter';
|
||||
import Loading from './loading/LoadingComponent';
|
||||
import ServerConnections from './ServerConnections';
|
||||
import globalize from '../scripts/globalize';
|
||||
import { ConnectionState } from '../utils/jellyfin-apiclient/ConnectionState';
|
||||
|
||||
enum BounceRoutes {
|
||||
Home = '/home.html',
|
||||
|
@ -14,14 +16,6 @@ enum BounceRoutes {
|
|||
StartWizard = '/wizardstart.html'
|
||||
}
|
||||
|
||||
// TODO: This should probably be in the SDK
|
||||
enum ConnectionState {
|
||||
SignedIn = 'SignedIn',
|
||||
ServerSignIn = 'ServerSignIn',
|
||||
ServerSelection = 'ServerSelection',
|
||||
ServerUpdateNeeded = 'ServerUpdateNeeded'
|
||||
}
|
||||
|
||||
type ConnectionRequiredProps = {
|
||||
isAdminRequired?: boolean,
|
||||
isUserRequired?: boolean
|
||||
|
@ -42,7 +36,7 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
|||
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const bounce = async (connectionResponse: any) => {
|
||||
const bounce = async (connectionResponse: ConnectResponse) => {
|
||||
switch (connectionResponse.State) {
|
||||
case ConnectionState.SignedIn:
|
||||
// Already logged in, bounce to the home page
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue