Fix: minor

This commit is contained in:
eight 2020-02-02 00:07:43 +08:00
parent b66b015252
commit 508cbf26a3
4 changed files with 16 additions and 6 deletions

View File

@ -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 => {

View File

@ -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;
}

View File

@ -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};

View File

@ -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});
}