From 240d62fb55c6a31d769dc687d2debfd7d3835284 Mon Sep 17 00:00:00 2001 From: Parvchannel Date: Sat, 25 Jan 2025 22:36:15 +0530 Subject: [PATCH] #1309 add confirm sorting dialoge --- src/js/content-script.js | 7 +++++++ src/js/popup.js | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/js/content-script.js b/src/js/content-script.js index fba6e096..e1909f7c 100644 --- a/src/js/content-script.js +++ b/src/js/content-script.js @@ -45,3 +45,10 @@ async function addMessage(message) { browser.runtime.onMessage.addListener((message) => { addMessage(message); }); + +browser.runtime.onMessage.addListener(message => { + if (message.action === 'confirmSortDialogue') { + const result = confirm("confirm sorting tabs"); + return Promise.resolve({result}); + } +}); \ No newline at end of file diff --git a/src/js/popup.js b/src/js/popup.js index 61a3fdaf..40ebb75b 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -756,16 +756,22 @@ Logic.registerPanel(P_CONTAINERS_LIST, { Utils.addEnterHandler(document.querySelector("#always-open-in"), () => { Logic.showPanel(ALWAYS_OPEN_IN_PICKER); }); + Utils.addEnterHandler(document.querySelector("#sort-containers-link"), async () => { - try { - await browser.runtime.sendMessage({ - method: "sortTabs" - }); - window.close(); - } catch (e) { - window.close(); + + const [tab] = await browser.tabs.query({currentWindow: true, active: true}); + + // sort without dialouge if active page dosent have content script + if(!/^(https?|wss?|file):/.test(tab.url)) { + browser.runtime.sendMessage({method: "sortTabs"}); + return; } + + const {result} = await browser.tabs.sendMessage(tab.id, {action: 'confirmSortDialogue'}); + if(result)browser.runtime.sendMessage({method: "sortTabs"}); + window.close(); }); + const mozillaVpnToutName = "moz-tout-main-panel"; const mozillaVpnPermissionsWarningDotName = "moz-permissions-warning-dot";