1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Optimize loading controller and view

This commit is contained in:
Bill Thornton 2022-10-25 12:39:12 -04:00
parent 7c96c386c2
commit 2094a7a8c2

View file

@ -16,6 +16,7 @@ export interface ViewManagerPageProps {
/** /**
* Page component that renders legacy views via the ViewManager. * Page component that renders legacy views via the ViewManager.
* NOTE: Any new pages should use the generic Page component instead.
*/ */
const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({ const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
controller, controller,
@ -30,10 +31,11 @@ const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
useEffect(() => { useEffect(() => {
const loadPage = async () => { const loadPage = async () => {
const controllerFactory = await import(/* webpackChunkName: "[request]" */ `../../controllers/${controller}`); const [ controllerFactory, viewHtml ] = await Promise.all([
import(/* webpackChunkName: "[request]" */ `../../controllers/${controller}`),
let viewHtml = await import(/* webpackChunkName: "[request]" */ `../../controllers/${view}`); import(/* webpackChunkName: "[request]" */ `../../controllers/${view}`)
viewHtml = globalize.translateHtml(viewHtml); .then(html => globalize.translateHtml(html))
]);
const viewOptions = { const viewOptions = {
url: location.pathname + location.search, url: location.pathname + location.search,