From e16b081bd304be24f75c6420edb4441fb62e0e44 Mon Sep 17 00:00:00 2001 From: mbnuqw Date: Wed, 8 Jan 2020 20:22:16 +0500 Subject: [PATCH 1/3] Fixed: Wrong tab position for 'external' tabs --- src/sidebar/actions/tabs.js | 9 +++++++++ src/sidebar/handlers/tabs.js | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/sidebar/actions/tabs.js b/src/sidebar/actions/tabs.js index bbd60e6cf..2b0b3d368 100644 --- a/src/sidebar/actions/tabs.js +++ b/src/sidebar/actions/tabs.js @@ -1641,6 +1641,15 @@ async function dropToTabsNative(event, dropIndex, dropParent, destCtx, pin) { } if (url && destCtx) { + let panel = this.state.panels[this.state.panelIndex] + if (panel && panel.tabs) { + if (!this.state.newTabsPosition) this.state.newTabsPosition = {} + this.state.newTabsPosition[dropIndex] = { + parent: dropParent < 0 ? undefined : dropParent, + panel: panel.id, + } + } + browser.tabs.create({ active: true, url, diff --git a/src/sidebar/handlers/tabs.js b/src/sidebar/handlers/tabs.js index 61589b624..838b31dd7 100644 --- a/src/sidebar/handlers/tabs.js +++ b/src/sidebar/handlers/tabs.js @@ -46,6 +46,8 @@ function onTabCreated(tab) { index = this.actions.getIndexForNewTab(panel, tab) tab.openerTabId = this.actions.getParentForNewTab(panel, tab.openerTabId) if (index === undefined) { + let prevTab = this.state.tabs[tab.index - 1] + if (prevTab && prevTab.panelId !== panel.id) panel = this.state.panelsMap[prevTab.panelId] if (panel.moveTabCtx !== 'none' && tab.openerTabId === undefined) { index = panel.tabs.length ? panel.endIndex + 1 : panel.endIndex } else { From 6540175fa9940a0f65a7657173a1c85df4e92c3d Mon Sep 17 00:00:00 2001 From: mbnuqw Date: Wed, 8 Jan 2020 21:06:13 +0500 Subject: [PATCH 2/3] Fixed: Auto-fold branches except the last X active: Check the lastAccessed time of child tabs too --- src/sidebar/actions/tabs.js | 9 ++++++++- src/sidebar/handlers/tabs.js | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/sidebar/actions/tabs.js b/src/sidebar/actions/tabs.js index 2b0b3d368..93c0ab032 100644 --- a/src/sidebar/actions/tabs.js +++ b/src/sidebar/actions/tabs.js @@ -1308,7 +1308,14 @@ function expTabsBranch(tabId) { // Auto fold if (this.state.autoFoldTabs) { - autoFold.sort((a, b) => a.lastAccessed - b.lastAccessed) + autoFold.sort((a, b) => { + let aMax = a.lastAccessed + let bMax = b.lastAccessed + if (a.childLastAccessed) aMax = Math.max(a.lastAccessed, a.childLastAccessed) + if (b.childLastAccessed) bMax = Math.max(b.lastAccessed, b.childLastAccessed) + return aMax - bMax + }) + if (this.state.autoFoldTabsExcept > 0) { autoFold = autoFold.slice(0, -this.state.autoFoldTabsExcept) } diff --git a/src/sidebar/handlers/tabs.js b/src/sidebar/handlers/tabs.js index 838b31dd7..ee2699207 100644 --- a/src/sidebar/handlers/tabs.js +++ b/src/sidebar/handlers/tabs.js @@ -671,19 +671,34 @@ function onTabActivated(info) { // Remove updated flag tab.updated = false let panel = this.state.panelsMap[tab.panelId] + if (!panel) return + if (panel) { let i = panel.updated.indexOf(tab.id) panel.updated.splice(i, 1) } - // Find panel of activated tab - if (!panel) return - // Switch to activated tab's panel if (!tab.pinned && (!currentPanel || !currentPanel.lockedPanel)) { this.actions.setPanel(panel.index) } + // Propagate access time to parent tabs for autoFolding feature + if ( + this.state.tabsTree && + tab.parentId > -1 && + this.state.autoFoldTabs && + this.state.autoFoldTabsExcept > 0 + ) { + let parent = this.state.tabsMap[tab.parentId] + if (parent) { + parent.childLastAccessed = tab.lastAccessed + while ((parent = this.state.tabsMap[parent.parentId])) { + parent.childLastAccessed = tab.lastAccessed + } + } + } + // Auto expand tabs group if (this.state.autoExpandTabs && tab.isParent && tab.folded && !this.dragMode) { let prevActiveChild From 0e61b163a44cfe0c94b759120cfc8383d5768363 Mon Sep 17 00:00:00 2001 From: mbnuqw Date: Wed, 8 Jan 2020 21:27:17 +0500 Subject: [PATCH 3/3] Bump version v4.1.2 --- addon/manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/manifest.json b/addon/manifest.json index 15431b27b..9084973e0 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -8,7 +8,7 @@ }, "author": "mbnuqw", "name": "__MSG_ExtName__", - "version": "4.1.1", + "version": "4.1.2", "default_locale": "en", "description": "__MSG_ExtDesc__", "homepage_url": "https://github.com/mbnuqw/sidebery", diff --git a/package.json b/package.json index ab3a56b66..dcecdc84e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sidebery", - "version": "4.1.1", + "version": "4.1.2", "description": "Manage your tabs and bookmarks in sidebar", "main": "index.js", "scripts": {