mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add appType support for legacy routes
This commit is contained in:
parent
93ef17a132
commit
80a26d5822
2 changed files with 33 additions and 3 deletions
|
@ -6,8 +6,10 @@ import globalize from 'lib/globalize';
|
|||
import type { RestoreViewFailResponse } from 'types/viewManager';
|
||||
|
||||
import viewManager from './viewManager';
|
||||
import { AppType } from 'constants/appType';
|
||||
|
||||
export interface ViewManagerPageProps {
|
||||
appType?: AppType
|
||||
controller: string
|
||||
view: string
|
||||
type?: string
|
||||
|
@ -31,7 +33,12 @@ interface ViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
const loadView = async (controller: string, view: string, viewOptions: ViewOptions) => {
|
||||
const loadView = async (
|
||||
appType: AppType,
|
||||
controller: string,
|
||||
view: string,
|
||||
viewOptions: ViewOptions
|
||||
) => {
|
||||
const [ controllerFactory, viewHtml ] = await Promise.all([
|
||||
import(/* webpackChunkName: "[request]" */ `../../controllers/${controller}`),
|
||||
import(/* webpackChunkName: "[request]" */ `../../controllers/${view}`)
|
||||
|
@ -50,6 +57,7 @@ const loadView = async (controller: string, view: string, viewOptions: ViewOptio
|
|||
* NOTE: Any new pages should use the generic Page component instead.
|
||||
*/
|
||||
const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
|
||||
appType = AppType.Stable,
|
||||
controller,
|
||||
view,
|
||||
type,
|
||||
|
@ -78,7 +86,7 @@ const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
|
|||
|
||||
if (navigationType !== Action.Pop) {
|
||||
console.debug('[ViewManagerPage] loading view [%s]', view);
|
||||
return loadView(controller, view, viewOptions);
|
||||
return loadView(appType, controller, view, viewOptions);
|
||||
}
|
||||
|
||||
console.debug('[ViewManagerPage] restoring view [%s]', view);
|
||||
|
@ -86,7 +94,7 @@ const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
|
|||
.catch(async (result?: RestoreViewFailResponse) => {
|
||||
if (!result?.cancelled) {
|
||||
console.debug('[ViewManagerPage] restore failed; loading view [%s]', view);
|
||||
return loadView(controller, view, viewOptions);
|
||||
return loadView(appType, controller, view, viewOptions);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue