Skip to content

Commit

Permalink
#1309 add confirm sorting dialoge
Browse files Browse the repository at this point in the history
  • Loading branch information
Parvchannel committed Jan 25, 2025
1 parent 037a804 commit 240d62f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/js/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
});
20 changes: 13 additions & 7 deletions src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 240d62f

Please sign in to comment.