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();
|
||||
|
||||
useEffect(() => {
|
||||
const loadPage = async () => {
|
||||
const [ controllerFactory, viewHtml ] = await Promise.all([
|
||||
import(/* webpackChunkName: "[request]" */ `../../controllers/${controller}`),
|
||||
import(/* webpackChunkName: "[request]" */ `../../controllers/${view}`)
|
||||
.then(html => globalize.translateHtml(html))
|
||||
]);
|
||||
|
||||
const loadPage = () => {
|
||||
const viewOptions = {
|
||||
url: location.pathname + location.search,
|
||||
controllerFactory,
|
||||
view: viewHtml,
|
||||
type,
|
||||
state: location.state,
|
||||
autoFocus: false,
|
||||
|
@ -53,9 +45,19 @@ const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
|
|||
};
|
||||
|
||||
viewManager.tryRestoreView(viewOptions)
|
||||
.catch((result?: any) => {
|
||||
.catch(async (result?: any) => {
|
||||
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