From bf31a733a73ee978ac2ee89aa322baf63875f32a Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Fri, 16 Jan 2026 11:32:45 -0500 Subject: [PATCH] Restore back button in experimental layout for apps --- .../experimental/components/AppToolbar/index.tsx | 14 ++++++-------- src/components/router/appRouter.js | 6 ++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/apps/experimental/components/AppToolbar/index.tsx b/src/apps/experimental/components/AppToolbar/index.tsx index 308b96826a..b73b9b5bea 100644 --- a/src/apps/experimental/components/AppToolbar/index.tsx +++ b/src/apps/experimental/components/AppToolbar/index.tsx @@ -2,6 +2,7 @@ import Stack from '@mui/material/Stack'; import React, { type FC } from 'react'; import { useLocation } from 'react-router-dom'; +import { appRouter, PUBLIC_PATHS } from 'components/router/appRouter'; import AppToolbar from 'components/toolbar/AppToolbar'; import ServerButton from 'components/toolbar/ServerButton'; @@ -16,14 +17,6 @@ interface AppToolbarProps { onDrawerButtonClick: (event: React.MouseEvent) => void } -const PUBLIC_PATHS = [ - '/addserver', - '/selectserver', - '/login', - '/forgotpassword', - '/forgotpasswordpin' -]; - const ExperimentalAppToolbar: FC = ({ isDrawerAvailable, isDrawerOpen, @@ -34,6 +27,10 @@ const ExperimentalAppToolbar: FC = ({ // The video osd does not show the standard toolbar if (location.pathname === '/video') return null; + // Only show the back button in apps when appropriate + const isBackButtonAvailable = window.NativeShell && appRouter.canGoBack(location.pathname); + + // Check if the current path is a public path to hide user content const isPublicPath = PUBLIC_PATHS.includes(location.pathname); return ( @@ -48,6 +45,7 @@ const ExperimentalAppToolbar: FC = ({ isDrawerAvailable={isDrawerAvailable} isDrawerOpen={isDrawerOpen} onDrawerButtonClick={onDrawerButtonClick} + isBackButtonAvailable={isBackButtonAvailable} isUserMenuAvailable={!isPublicPath} > {!isDrawerAvailable && ( diff --git a/src/components/router/appRouter.js b/src/components/router/appRouter.js index 032ddfaf1e..52964bdd4e 100644 --- a/src/components/router/appRouter.js +++ b/src/components/router/appRouter.js @@ -16,7 +16,7 @@ import { history } from 'RootAppRouter'; const START_PAGE_PATHS = ['/home', '/login', '/selectserver']; /** Pages that do not require a user to be logged in to view. */ -const PUBLIC_PATHS = [ +export const PUBLIC_PATHS = [ '/addserver', '/selectserver', '/login', @@ -121,9 +121,7 @@ class AppRouter { return this.baseRoute; } - canGoBack() { - const path = history.location.pathname; - + canGoBack(path = history.location.pathname) { if ( !document.querySelector('.dialogContainer') && START_PAGE_PATHS.includes(path)