mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 10:58:20 -07:00
Optimize restoring views
This commit is contained in:
parent
20f8f4a745
commit
698de36178
@ -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…
Reference in New Issue
Block a user