diff --git a/background/background.js b/background/background.js index b14da773..1e937b12 100644 --- a/background/background.js +++ b/background/background.js @@ -400,7 +400,15 @@ function onRuntimeMessage(msg, sender) { } function openEditor(params) { - const searchParams = new URLSearchParams(); // FIXME: use url.searchParams when Chrome >= 51 + /* Open the editor. Activate if it is already opened + + params: { + id?: Number, + domain?: String, + 'url-prefix'?: String + } + */ + const searchParams = new URLSearchParams(); for (const key in params) { searchParams.set(key, params[key]); } @@ -432,7 +440,7 @@ function openManage({options = false, search} = {}) { return Promise.all([ activateTab(tab), tab.url !== url && msg.sendTab(tab.id, {method: 'pushState', url}) - .catch(console.warn) + .catch(console.error) ]); } return getActiveTab().then(tab => { diff --git a/js/messaging.js b/js/messaging.js index c2e4f704..a0237381 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -267,6 +267,7 @@ function openURL(options) { if (tab) { // update url if only hash is different? // we can't update URL if !url.includes('#') since it refreshes the page + // FIXME: should we move the tab (i.e. specifying index)? if (tab.url !== url && tab.url.split('#')[0] === url.split('#')[0] && url.includes('#')) { return activateTab(tab, {url, index}); @@ -278,7 +279,8 @@ function openURL(options) { } return getActiveTab().then(tab => { if (isTabReplaceable(tab, url)) { - return activateTab(tab, {url, index}); + // don't move the tab in this case + return activateTab(tab, {url}); } const options = {url, index, active}; // FF57+ supports openerTabId, but not in Android (indicated by the absence of chrome.windows) @@ -298,7 +300,7 @@ function isTabReplaceable(tab, newUrl) { if (!tab || !URLS.emptyTab.includes(tab.url)) { return false; } - // FIXME: why? + // FIXME: but why? if (tab.incognito && newUrl.startsWith('chrome')) { return false; } diff --git a/js/router.js b/js/router.js index 175affb5..59566b59 100644 --- a/js/router.js +++ b/js/router.js @@ -12,6 +12,7 @@ const router = (() => { if (e.method === 'pushState' && e.url !== location.href) { history.pushState(history.state, null, e.url); update(); + return true; } }); return {watch, updateSearch, getSearch, updateHash}; diff --git a/manage/filters.js b/manage/filters.js index d027b815..11e11feb 100644 --- a/manage/filters.js +++ b/manage/filters.js @@ -15,6 +15,7 @@ router.watch({search: ['search']}, ([search]) => { $('#search').value = search || ''; if (!initialized) { init(); + initialized = true; } else { searchStyles(); } @@ -136,8 +137,6 @@ function init() { } }); - initialized = true; - filterOnChange({forceRefilter: true}); }