Skip to content

Commit

Permalink
Restructure initialization to try and reduce chance of groupless tabs…
Browse files Browse the repository at this point in the history
… on start up
  • Loading branch information
photodiode committed Oct 21, 2021
1 parent 6d6f31d commit c9a6f9a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
16 changes: 9 additions & 7 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
Expand Down
15 changes: 7 additions & 8 deletions src/background/tabEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions src/panorama/js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"');
}


Expand Down

0 comments on commit c9a6f9a

Please sign in to comment.