Skip to content

Commit

Permalink
Remove app router routing
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill committed Sep 6, 2024
1 parent 9d6e266 commit 99b2bd4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 346 deletions.
31 changes: 13 additions & 18 deletions src/components/ConnectionRequired.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Outlet, useLocation, useNavigate } from 'react-router-dom';
import type { ConnectResponse } from 'jellyfin-apiclient';

import alert from './alert';
import { appRouter } from './router/appRouter';
import Loading from './loading/LoadingComponent';
import ServerConnections from './ServerConnections';
import globalize from '../lib/globalize';
Expand Down Expand Up @@ -149,24 +148,20 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
}, [bounce, isAdminRequired, isUserRequired]);

useEffect(() => {
// TODO: appRouter will call appHost.exit() if navigating back when you are already at the default route.
// This case will need to be handled elsewhere before appRouter can be killed.

// Check connection status on initial page load
const firstConnection = appRouter.firstConnectionResult;
appRouter.firstConnectionResult = null;

if (firstConnection && firstConnection.State !== ConnectionState.SignedIn) {
handleIncompleteWizard(firstConnection)
.catch(err => {
console.error('[ConnectionRequired] failed to start wizard', err);
});
} else {
validateUserAccess()
.catch(err => {
console.error('[ConnectionRequired] failed to validate user access', err);
});
}
ServerConnections.connect()
.then(firstConnection => {
console.debug('[ConnectionRequired] connection state', firstConnection?.State);

if (firstConnection && firstConnection.State !== ConnectionState.SignedIn) {
return handleIncompleteWizard(firstConnection);
} else {
return validateUserAccess();
}
})
.catch(err => {
console.error('[ConnectionRequired] failed to connect to server', err);
});
}, [handleIncompleteWizard, validateUserAccess]);

if (isLoading) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/nowPlayingBar/nowPlayingBar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { appRouter, isLyricsPage } from 'components/router/appRouter';
import datetime from '../../scripts/datetime';
import Events from '../../utils/events.ts';
import browser from '../../scripts/browser';
Expand All @@ -16,7 +17,6 @@ import appFooter from '../appFooter/appFooter';
import itemShortcuts from '../shortcuts';
import './nowPlayingBar.scss';
import '../../elements/emby-slider/emby-slider';
import { appRouter } from '../router/appRouter';

let currentPlayer;
let currentPlayerSupportedCommands = [];
Expand Down Expand Up @@ -773,7 +773,7 @@ function refreshFromPlayer(player, type) {
}

function bindToPlayer(player) {
isLyricPageActive = appRouter.currentRouteInfo.path.toLowerCase() === '/lyrics';
isLyricPageActive = isLyricsPage();
if (player === currentPlayer) {
return;
}
Expand Down Expand Up @@ -806,7 +806,7 @@ Events.on(playbackManager, 'playerchange', function () {
bindToPlayer(playbackManager.getCurrentPlayer());

document.addEventListener('viewbeforeshow', function (e) {
isLyricPageActive = appRouter.currentRouteInfo.path.toLowerCase() === '/lyrics';
isLyricPageActive = isLyricsPage();
setLyricButtonActiveStatus();
if (!e.detail.options.enableMediaControl) {
if (isVisibilityAllowed) {
Expand Down
Loading

0 comments on commit 99b2bd4

Please sign in to comment.