Skip to content

Commit

Permalink
ENH prevent multiple confirm dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala authored and GuySartorelli committed Apr 18, 2023
1 parent eaf8608 commit 0524bc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
.DS_Store
host-map.php
node_modules
6 changes: 6 additions & 0 deletions client/javascript/LeftAndMain_Subsites.js
Expand Up @@ -9,16 +9,22 @@
*/
function detectSubsiteChange(selectedId) {
var sessionKey = "admin_subsite_id";
var reloadPending = false;
try {
localStorage.setItem(sessionKey, selectedId);

window.addEventListener("storage", function () {
if (reloadPending) {
return;
}
var tabId = localStorage.getItem(sessionKey);
if (tabId && selectedId != tabId) {
var msg = ss.i18n._t("Admin.SUBSITECHANGED", "You've changed subsite in another tab, do you want to reload the page?");
reloadPending = true; // Don't trigger multiple confirm dialog
if (confirm(msg)) {
window.location.reload();
}
// Don't ask again if cancelled
}
});
} catch (e) {
Expand Down

0 comments on commit 0524bc5

Please sign in to comment.