mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix error dialog history
This commit is contained in:
parent
2af0b91dad
commit
3567b9783d
4 changed files with 41 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
|||
|
||||
import { appRouter } from './appRouter';
|
||||
import browser from '../scripts/browser';
|
||||
import dialog from './dialog/dialog';
|
||||
import globalize from '../scripts/globalize';
|
||||
|
@ -10,7 +10,7 @@ import globalize from '../scripts/globalize';
|
|||
return originalString.replace(reg, strWith);
|
||||
}
|
||||
|
||||
export default function (text, title) {
|
||||
export default async function (text, title) {
|
||||
let options;
|
||||
if (typeof text === 'string') {
|
||||
options = {
|
||||
|
@ -22,7 +22,9 @@ import globalize from '../scripts/globalize';
|
|||
}
|
||||
|
||||
if (browser.tv && window.alert) {
|
||||
await appRouter.ready();
|
||||
alert(replaceAll(options.text || '', '<br/>', '\n'));
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
const items = [];
|
||||
|
||||
|
@ -35,8 +37,6 @@ import globalize from '../scripts/globalize';
|
|||
options.buttons = items;
|
||||
return dialog.show(options);
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -24,6 +24,7 @@ class AppRouter {
|
|||
isDummyBackToHome;
|
||||
msgTimeout;
|
||||
popstateOccurred = false;
|
||||
promiseShow;
|
||||
resolveOnNextShow;
|
||||
previousRoute = {};
|
||||
/**
|
||||
|
@ -122,11 +123,24 @@ class AppRouter {
|
|||
}
|
||||
}
|
||||
|
||||
back() {
|
||||
page.back();
|
||||
ready() {
|
||||
return this.promiseShow || Promise.resolve();
|
||||
}
|
||||
|
||||
show(path, options) {
|
||||
async back() {
|
||||
if (this.promiseShow) await this.promiseShow;
|
||||
|
||||
this.promiseShow = new Promise((resolve) => {
|
||||
this.resolveOnNextShow = resolve;
|
||||
page.back();
|
||||
});
|
||||
|
||||
return this.promiseShow;
|
||||
}
|
||||
|
||||
async show(path, options) {
|
||||
if (this.promiseShow) await this.promiseShow;
|
||||
|
||||
// ensure the path does not start with '#!' since the router adds this
|
||||
if (path.startsWith('#!')) {
|
||||
path = path.substring(2);
|
||||
|
@ -146,17 +160,25 @@ class AppRouter {
|
|||
}
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
this.promiseShow = new Promise((resolve) => {
|
||||
this.resolveOnNextShow = resolve;
|
||||
page.show(path, options);
|
||||
// Schedule a call to return the promise
|
||||
setTimeout(() => page.show(path, options), 0);
|
||||
});
|
||||
|
||||
return this.promiseShow;
|
||||
}
|
||||
|
||||
showDirect(path) {
|
||||
return new Promise(function(resolve) {
|
||||
async showDirect(path) {
|
||||
if (this.promiseShow) await this.promiseShow;
|
||||
|
||||
this.promiseShow = new Promise((resolve) => {
|
||||
this.resolveOnNextShow = resolve;
|
||||
page.show(this.baseUrl() + path);
|
||||
// Schedule a call to return the promise
|
||||
setTimeout(() => page.show(this.baseUrl() + path), 0);
|
||||
});
|
||||
|
||||
return this.promiseShow;
|
||||
}
|
||||
|
||||
start(options) {
|
||||
|
@ -414,6 +436,7 @@ class AppRouter {
|
|||
onViewShow() {
|
||||
const resolve = this.resolveOnNextShow;
|
||||
if (resolve) {
|
||||
this.promiseShow = null;
|
||||
this.resolveOnNextShow = null;
|
||||
resolve();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { appRouter } from '../appRouter';
|
||||
import browser from '../../scripts/browser';
|
||||
import dialog from '../dialog/dialog';
|
||||
import globalize from '../../scripts/globalize';
|
||||
|
@ -6,7 +7,7 @@ function replaceAll(str, find, replace) {
|
|||
return str.split(find).join(replace);
|
||||
}
|
||||
|
||||
function nativeConfirm(options) {
|
||||
async function nativeConfirm(options) {
|
||||
if (typeof options === 'string') {
|
||||
options = {
|
||||
title: '',
|
||||
|
@ -15,6 +16,7 @@ function nativeConfirm(options) {
|
|||
}
|
||||
|
||||
const text = replaceAll(options.text || '', '<br/>', '\n');
|
||||
await appRouter.ready();
|
||||
const result = window.confirm(text);
|
||||
|
||||
if (result) {
|
||||
|
|
|
@ -184,7 +184,9 @@ import '../../assets/css/scrollstyles.scss';
|
|||
return dlg.getAttribute('data-history') === 'true';
|
||||
}
|
||||
|
||||
export function open(dlg) {
|
||||
export async function open(dlg) {
|
||||
await appRouter.ready();
|
||||
|
||||
if (globalOnOpenCallback) {
|
||||
globalOnOpenCallback(dlg);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue