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