Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnuqw committed Jan 8, 2020
2 parents 8f56b6f + 0e61b16 commit 526373a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
18 changes: 17 additions & 1 deletion src/sidebar/actions/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -1641,6 +1648,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,
Expand Down
23 changes: 20 additions & 3 deletions src/sidebar/handlers/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -669,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
Expand Down

0 comments on commit 526373a

Please sign in to comment.