diff --git a/addon/manifest.json b/addon/manifest.json index f723361e..e93cd744 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -8,7 +8,7 @@ }, "author": "mbnuqw", "name": "__MSG_ExtName__", - "version": "4.0.1", + "version": "4.0.2", "default_locale": "en", "description": "__MSG_ExtDesc__", "homepage_url": "https://github.com/mbnuqw/sidebery", diff --git a/package.json b/package.json index 776524a1..d7ab2b28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sidebery", - "version": "4.0.1", + "version": "4.0.2", "description": "Manage your tabs and bookmarks in sidebar", "main": "index.js", "scripts": { diff --git a/src/page.settings/actions/misc.js b/src/page.settings/actions/misc.js index b5cf3089..11fac10b 100644 --- a/src/page.settings/actions/misc.js +++ b/src/page.settings/actions/misc.js @@ -64,15 +64,12 @@ async function loadPermissions(init) { } } -async function goToPerm(hash, permId) { +function goToPerm(permId) { + if (!this.state.settingsRefs) return let scrollHighlightConf = { behavior: 'smooth', block: 'center' } + let el = this.state.settingsRefs[permId] - await this.actions.waitForInit() - - if (hash !== undefined && this.state.settingsRefs) { - let el = this.state.settingsRefs[permId] - if (el) el.scrollIntoView(scrollHighlightConf) - } + if (el) el.scrollIntoView(scrollHighlightConf) document.title = 'Sidebery / Settings' this.state.activeView = 'Settings' @@ -82,22 +79,13 @@ async function goToPerm(hash, permId) { /** * Check url hash and update active view */ -function updateActiveView() { +async function updateActiveView() { let hash = location.hash ? location.hash.slice(1) : location.hash let hashArg = hash.split('.') hash = hashArg[0] let arg = hashArg[1] let scrollSectionConf = { behavior: 'smooth', block: 'start' } - if (hash === 'all-urls') return this.actions.goToPerm(hash, 'all_urls') - if (hash === 'tab-hide') return this.actions.goToPerm(hash, 'tab_hide') - if (hash === 'clipboard-write') { - return this.actions.goToPerm(hash, 'clipboard_write') - } - if (hash === 'web-request-blocking') { - return this.actions.goToPerm(hash, 'web_request_blocking') - } - if (this.__navLockTimeout) clearTimeout(this.__navLockTimeout) this.state.navLock = true this.state.activeSection = hash @@ -105,6 +93,13 @@ function updateActiveView() { this.state.navLock = false }, 1250) + await this.actions.waitForInit() + + if (hash === 'all-urls') return this.actions.goToPerm('all_urls') + if (hash === 'tab-hide') return this.actions.goToPerm('tab_hide') + if (hash === 'clipboard-write') return this.actions.goToPerm('clipboard_write') + if (hash === 'web-request-blocking') return this.actions.goToPerm('web_request_blocking') + if (hash.startsWith('menu_editor')) { setTimeout( () => { diff --git a/src/sidebar/actions/panels.js b/src/sidebar/actions/panels.js index 720f0416..87b4a9c1 100644 --- a/src/sidebar/actions/panels.js +++ b/src/sidebar/actions/panels.js @@ -34,6 +34,7 @@ async function updatePanels(newPanels) { } } + let activePanel = this.state.panels[this.state.panelIndex] let panels = [] let panelsMap = {} let updateNeeded = false @@ -77,13 +78,16 @@ async function updatePanels(newPanels) { this.state.panels = panels this.state.panelsMap = panelsMap + let activePanelIndex = this.state.panels.indexOf(activePanel) + if (activePanelIndex !== -1) this.state.panelIndex = activePanelIndex + if (updateNeeded) this.actions.updatePanelsTabs() if (reloadNeeded) { this.handlers.resetTabsListeners() - let index = 0 + let index = this.getters.pinnedTabs.length let windowId = this.state.windowId - let allTabs = [] + let allTabs = [...this.getters.pinnedTabs] for (let panel of this.state.panels) { if (!panel.tabs || !panel.tabs.length) continue for (let tab of panel.tabs) {