From c9a6f9a0fae584ca2078db751948a1db1d232045 Mon Sep 17 00:00:00 2001 From: photodiode <16804570+photodiode@users.noreply.github.com> Date: Thu, 21 Oct 2021 14:12:53 +0900 Subject: [PATCH] Restructure initialization to try and reduce chance of groupless tabs on start up --- src/background/background.js | 16 +++++++++------- src/background/tabEvents.js | 15 +++++++-------- src/manifest.json | 2 +- src/panorama/js/view.js | 2 -- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/background/background.js b/src/background/background.js index 26d2629..6716987 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -101,6 +101,15 @@ async function init() { await migrate(); // keep until everyone's on 0.9.0 + handleTabEvents(); + + browser.commands.onCommand.addListener(handleCommands); + browser.browserAction.onClicked.addListener(core.toggleView); + + browser.windows.onCreated.addListener(createGroupInWindow); + + await salvageGrouplessTabs(); + // meny entries browser.menus.create({ id: 'newTabGroup', @@ -123,13 +132,6 @@ async function init() { browser.tabs.remove(tab.id); } // ---- - - browser.commands.onCommand.addListener(handleCommands); - browser.browserAction.onClicked.addListener(core.toggleView); - - browser.windows.onCreated.addListener(createGroupInWindow); - - handleTabEvents(); // auto bakup backup.start(); diff --git a/src/background/tabEvents.js b/src/background/tabEvents.js index ad4c400..a67f677 100644 --- a/src/background/tabEvents.js +++ b/src/background/tabEvents.js @@ -91,15 +91,14 @@ async function activated(activeInfo) { if (!tab.pinned) { // Set the window's active group to the new active tab's group - let activeGroupId = undefined; - while (activeGroupId == undefined) { - activeGroupId = await addon.tabs.getGroupId(activeInfo.tabId); - } - - if (activeGroupId != -1) { - addon.tabGroups.setActiveId(tab.windowId, activeGroupId); + let newGroupId = undefined; + while (newGroupId == undefined) { + newGroupId = await addon.tabs.getGroupId(activeInfo.tabId); } - core.toggleVisibleTabs(tab.windowId, activeGroupId); + if (newGroupId != -1) { + addon.tabGroups.setActiveId(tab.windowId, newGroupId); + } + core.toggleVisibleTabs(tab.windowId, newGroupId); } } diff --git a/src/manifest.json b/src/manifest.json index 5510fd2..faa8bfa 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Panorama View", "description": "Tab Groups with Panorama View", - "version": "0.9.1", + "version": "0.9.2", "icons": { "16": "gfx/logo/logo-16.png", "24": "gfx/logo/logo-24.png", diff --git a/src/panorama/js/view.js b/src/panorama/js/view.js index 8967c22..1ac45f0 100644 --- a/src/panorama/js/view.js +++ b/src/panorama/js/view.js @@ -108,8 +108,6 @@ async function initialize() { document.getElementById('groups').addEventListener('dragover', drag.viewDragOver, false); document.getElementById('groups').addEventListener('drop', drag.viewDrop, false); // ---- - - //alert('To create a new Tab Group you can\n- Double click on an empty space\n- Drag a Tab to an empty space\n- Right click the Panorama View button and choose "New Tab Group"'); }