mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Optimize restoring views
This commit is contained in:
parent
20f8f4a745
commit
698de36178
1 changed files with 13 additions and 11 deletions
|
@ -30,17 +30,9 @@ const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadPage = async () => {
|
const loadPage = () => {
|
||||||
const [ controllerFactory, viewHtml ] = await Promise.all([
|
|
||||||
import(/* webpackChunkName: "[request]" */ `../../controllers/${controller}`),
|
|
||||||
import(/* webpackChunkName: "[request]" */ `../../controllers/${view}`)
|
|
||||||
.then(html => globalize.translateHtml(html))
|
|
||||||
]);
|
|
||||||
|
|
||||||
const viewOptions = {
|
const viewOptions = {
|
||||||
url: location.pathname + location.search,
|
url: location.pathname + location.search,
|
||||||
controllerFactory,
|
|
||||||
view: viewHtml,
|
|
||||||
type,
|
type,
|
||||||
state: location.state,
|
state: location.state,
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
|
@ -53,9 +45,19 @@ const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
viewManager.tryRestoreView(viewOptions)
|
viewManager.tryRestoreView(viewOptions)
|
||||||
.catch((result?: any) => {
|
.catch(async (result?: any) => {
|
||||||
if (!result || !result.cancelled) {
|
if (!result || !result.cancelled) {
|
||||||
viewManager.loadView(viewOptions);
|
const [ controllerFactory, viewHtml ] = await Promise.all([
|
||||||
|
import(/* webpackChunkName: "[request]" */ `../../controllers/${controller}`),
|
||||||
|
import(/* webpackChunkName: "[request]" */ `../../controllers/${view}`)
|
||||||
|
.then(html => globalize.translateHtml(html))
|
||||||
|
]);
|
||||||
|
|
||||||
|
viewManager.loadView({
|
||||||
|
...viewOptions,
|
||||||
|
controllerFactory,
|
||||||
|
view: viewHtml
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue