mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-19 20:08:20 -07:00
Remove nested Promise
This commit is contained in:
parent
eccaad366e
commit
748592fa93
@ -36,54 +36,56 @@ import 'css!components/viewManager/viewContainer';
|
|||||||
const newViewInfo = normalizeNewView(options, isPluginpage);
|
const newViewInfo = normalizeNewView(options, isPluginpage);
|
||||||
const newView = newViewInfo.elem;
|
const newView = newViewInfo.elem;
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
const currentPage = allPages[pageIndex];
|
||||||
const currentPage = allPages[pageIndex];
|
|
||||||
|
|
||||||
if (currentPage) {
|
if (currentPage) {
|
||||||
triggerDestroy(currentPage);
|
triggerDestroy(currentPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
let view = newView;
|
let view = newView;
|
||||||
|
|
||||||
if (typeof view == 'string') {
|
if (typeof view == 'string') {
|
||||||
view = document.createElement('div');
|
view = document.createElement('div');
|
||||||
view.innerHTML = newView;
|
view.innerHTML = newView;
|
||||||
}
|
}
|
||||||
|
|
||||||
view.classList.add('mainAnimatedPage');
|
view.classList.add('mainAnimatedPage');
|
||||||
|
|
||||||
if (currentPage) {
|
if (currentPage) {
|
||||||
if (newViewInfo.hasScript && window.$) {
|
if (newViewInfo.hasScript && window.$) {
|
||||||
mainAnimatedPages.removeChild(currentPage);
|
mainAnimatedPages.removeChild(currentPage);
|
||||||
view = $(view).appendTo(mainAnimatedPages)[0];
|
view = $(view).appendTo(mainAnimatedPages)[0];
|
||||||
} else {
|
|
||||||
mainAnimatedPages.replaceChild(view, currentPage);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (newViewInfo.hasScript && window.$) {
|
mainAnimatedPages.replaceChild(view, currentPage);
|
||||||
view = $(view).appendTo(mainAnimatedPages)[0];
|
|
||||||
} else {
|
|
||||||
mainAnimatedPages.appendChild(view);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (options.type) {
|
if (newViewInfo.hasScript && window.$) {
|
||||||
view.setAttribute('data-type', options.type);
|
view = $(view).appendTo(mainAnimatedPages)[0];
|
||||||
|
} else {
|
||||||
|
mainAnimatedPages.appendChild(view);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const properties = [];
|
if (options.type) {
|
||||||
|
view.setAttribute('data-type', options.type);
|
||||||
|
}
|
||||||
|
|
||||||
if (options.fullscreen) {
|
const properties = [];
|
||||||
properties.push('fullscreen');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (properties.length) {
|
if (options.fullscreen) {
|
||||||
view.setAttribute('data-properties', properties.join(','));
|
properties.push('fullscreen');
|
||||||
}
|
}
|
||||||
|
|
||||||
allPages[pageIndex] = view;
|
if (properties.length) {
|
||||||
|
view.setAttribute('data-properties', properties.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
allPages[pageIndex] = view;
|
||||||
|
|
||||||
|
return setControllerClass(view, options)
|
||||||
// Timeout for polyfilled CustomElements (webOS 1.2)
|
// Timeout for polyfilled CustomElements (webOS 1.2)
|
||||||
setControllerClass(view, options).then(() => new Promise((resolve) => setTimeout(resolve, 0))).then(() => {
|
.then(() => new Promise((resolve) => setTimeout(resolve, 0)))
|
||||||
|
.then(() => {
|
||||||
if (onBeforeChange) {
|
if (onBeforeChange) {
|
||||||
onBeforeChange(view, false, options);
|
onBeforeChange(view, false, options);
|
||||||
}
|
}
|
||||||
@ -101,9 +103,8 @@ import 'css!components/viewManager/viewContainer';
|
|||||||
$.mobile.activePage = view;
|
$.mobile.activePage = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(view);
|
return view;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user