From e5aeb2a20f6d20e92f4a7a4e173b7c3900534db9 Mon Sep 17 00:00:00 2001 From: dimden Date: Sun, 24 Sep 2023 17:21:29 +0300 Subject: [PATCH] fix closing dms jumping page to top --- layouts/header/script.js | 6 ++++-- layouts/profile/script.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/layouts/header/script.js b/layouts/header/script.js index d048070d..7c6982a6 100644 --- a/layouts/header/script.js +++ b/layouts/header/script.js @@ -4,7 +4,7 @@ let inboxData = []; let followRequestsData = []; let customSet = false; let menuFn; -let notificationsOpened = false; +let notificationsOpened = false, inboxOpened = false; let isDarkModeEnabled = typeof vars !== 'undefined' ? (vars.darkMode || (vars.timeMode && isDark())) : false; let activeTweet; let seenAlgoTweets = [], algoTweetsChanged = false; @@ -1090,6 +1090,7 @@ let userDataFunction = async user => { } document.getElementById('messages').addEventListener('click', async e => { e.preventDefault(); + inboxOpened = true; location.hash = '#dm'; let inbox = inboxData; @@ -1153,9 +1154,10 @@ let userDataFunction = async user => { `, "inbox-modal", () => { if(location.hash === '#dm') { - location.hash = ""; + location.hash = "##"; } tweetUrlToShareInDMs = null; + setTimeout(() => inboxOpened = false, 100); }); modal.querySelector('.modal-close').hidden = true; const inboxList = modal.querySelector('.inbox-list'); diff --git a/layouts/profile/script.js b/layouts/profile/script.js index 9daf9644..9869ac41 100644 --- a/layouts/profile/script.js +++ b/layouts/profile/script.js @@ -2128,7 +2128,7 @@ setTimeout(async () => { }); window.addEventListener("popstate", async () => { if(document.querySelector('.tweet-viewer')) return; - if(notificationsOpened) return; + if(notificationsOpened || inboxOpened) return; let path = location.pathname; if(path.endsWith("/")) path = path.substring(0, path.length - 1);