mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #3987 from dmitrylyzo/fix-dialog-closing
Fix dialog closing flow
This commit is contained in:
commit
b7b60e6bd0
2 changed files with 25 additions and 13 deletions
|
@ -57,6 +57,7 @@ import '../../assets/css/scrollstyles.scss';
|
||||||
|
|
||||||
if ((shouldClose || !isOpened(dlg)) && unlisten) {
|
if ((shouldClose || !isOpened(dlg)) && unlisten) {
|
||||||
unlisten();
|
unlisten();
|
||||||
|
unlisten = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldClose) {
|
if (shouldClose) {
|
||||||
|
@ -64,6 +65,22 @@ import '../../assets/css/scrollstyles.scss';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function finishClose() {
|
||||||
|
if (unlisten) {
|
||||||
|
unlisten();
|
||||||
|
unlisten = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg.dispatchEvent(new CustomEvent('close', {
|
||||||
|
bubbles: false,
|
||||||
|
cancelable: false
|
||||||
|
}));
|
||||||
|
|
||||||
|
resolve({
|
||||||
|
element: dlg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function onBackCommand(e) {
|
function onBackCommand(e) {
|
||||||
if (e.detail.command === 'back') {
|
if (e.detail.command === 'back') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -79,6 +96,7 @@ import '../../assets/css/scrollstyles.scss';
|
||||||
|
|
||||||
if (unlisten) {
|
if (unlisten) {
|
||||||
unlisten();
|
unlisten();
|
||||||
|
unlisten = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeBackdrop(dlg);
|
removeBackdrop(dlg);
|
||||||
|
@ -92,9 +110,13 @@ import '../../assets/css/scrollstyles.scss';
|
||||||
const state = history.location.state || {};
|
const state = history.location.state || {};
|
||||||
if (state.dialogs?.length > 0) {
|
if (state.dialogs?.length > 0) {
|
||||||
if (state.dialogs[state.dialogs.length - 1] === hash) {
|
if (state.dialogs[state.dialogs.length - 1] === hash) {
|
||||||
|
unlisten = history.listen(finishClose);
|
||||||
history.back();
|
history.back();
|
||||||
} else if (state.dialogs.includes(hash)) {
|
} else if (state.dialogs.includes(hash)) {
|
||||||
console.warn('[dialogHelper] dialog "%s" was closed, but is not the last dialog opened', hash);
|
console.warn('[dialogHelper] dialog "%s" was closed, but is not the last dialog opened', hash);
|
||||||
|
|
||||||
|
unlisten = history.listen(finishClose);
|
||||||
|
|
||||||
// Remove the closed dialog hash from the history state
|
// Remove the closed dialog hash from the history state
|
||||||
history.replace(
|
history.replace(
|
||||||
`${history.location.pathname}${history.location.search}`,
|
`${history.location.pathname}${history.location.search}`,
|
||||||
|
@ -123,18 +145,9 @@ import '../../assets/css/scrollstyles.scss';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//resolve();
|
if (!unlisten) {
|
||||||
// if we just called history.back(), then use a timeout to allow the history events to fire first
|
finishClose();
|
||||||
setTimeout(() => {
|
}
|
||||||
dlg.dispatchEvent(new CustomEvent('close', {
|
|
||||||
bubbles: false,
|
|
||||||
cancelable: false
|
|
||||||
}));
|
|
||||||
|
|
||||||
resolve({
|
|
||||||
element: dlg
|
|
||||||
});
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dlg.addEventListener('_close', onDialogClosed);
|
dlg.addEventListener('_close', onDialogClosed);
|
||||||
|
|
|
@ -238,7 +238,6 @@ function showWithUser(options, player, user) {
|
||||||
|
|
||||||
return actionsheet.show({
|
return actionsheet.show({
|
||||||
items: menuItems,
|
items: menuItems,
|
||||||
resolveOnClick: true,
|
|
||||||
positionTo: options.positionTo
|
positionTo: options.positionTo
|
||||||
}).then(function (id) {
|
}).then(function (id) {
|
||||||
return handleSelectedOption(id, options, player);
|
return handleSelectedOption(id, options, player);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue