diff --git a/src/components/viewManager/ViewManagerPage.tsx b/src/components/viewManager/ViewManagerPage.tsx index 30ab177306..843f2fe533 100644 --- a/src/components/viewManager/ViewManagerPage.tsx +++ b/src/components/viewManager/ViewManagerPage.tsx @@ -4,7 +4,7 @@ import { useLocation } from 'react-router-dom'; import globalize from '../../scripts/globalize'; import viewManager from './viewManager'; -interface ViewManagerPageProps { +export interface ViewManagerPageProps { controller: string view: string type?: string @@ -35,7 +35,7 @@ const ViewManagerPage: FunctionComponent = ({ let viewHtml = await import(/* webpackChunkName: "[request]" */ `../../controllers/${view}`); viewHtml = globalize.translateHtml(viewHtml); - viewManager.loadView({ + const viewOptions = { url: location.pathname + location.search, controllerFactory, view: viewHtml, @@ -48,7 +48,14 @@ const ViewManagerPage: FunctionComponent = ({ supportsThemeMedia: isThemeMediaSupported, enableMediaControl: isNowPlayingBarEnabled } - }); + }; + + viewManager.tryRestoreView(viewOptions) + .catch((result?: any) => { + if (!result || !result.cancelled) { + viewManager.loadView(viewOptions); + } + }); }; loadPage(); diff --git a/src/components/viewManager/viewManager.js b/src/components/viewManager/viewManager.js index 03138797c9..c9a64b658a 100644 --- a/src/components/viewManager/viewManager.js +++ b/src/components/viewManager/viewManager.js @@ -167,7 +167,7 @@ class ViewManager { } return viewContainer.tryRestoreView(options).then(function (view) { - onViewChanging(); + if (onViewChanging) onViewChanging(); onViewChange(view, options, true); }); }