Change: reuse editor in openEditor
This commit is contained in:
parent
f86a678a1f
commit
3b24e6a928
|
@ -403,13 +403,12 @@ function openEditor(params) {
|
|||
searchParams.set(key, params[key]);
|
||||
}
|
||||
const search = searchParams.toString();
|
||||
const url = chrome.runtime.getURL('edit.html') + (search && `?${search}`);
|
||||
if (chrome.windows && prefs.get('openEditInWindow')) {
|
||||
// FIXME: should we reuse the editor window?
|
||||
chrome.windows.create(Object.assign({url}, prefs.get('windowPosition')));
|
||||
} else {
|
||||
openURL({url});
|
||||
}
|
||||
return openURL({
|
||||
url: 'edit.html' + (search && `?${search}`),
|
||||
newWindow: prefs.get('openEditInWindow'),
|
||||
windowPosition: prefs.get('windowPosition'),
|
||||
currentWindow: null
|
||||
});
|
||||
}
|
||||
|
||||
function openManage({options = false, search} = {}) {
|
||||
|
|
|
@ -99,6 +99,7 @@ const updateTab = promisify(chrome.tabs.update.bind(chrome.tabs));
|
|||
const moveTabs = promisify(chrome.tabs.move.bind(chrome.tabs));
|
||||
// FIXME: is it possible that chrome.windows is undefined?
|
||||
const updateWindow = promisify(chrome.windows.update.bind(chrome.windows));
|
||||
const createWindow = promisify(chrome.windows.create.bind(chrome.windows));
|
||||
|
||||
function getTab(id) {
|
||||
return new Promise(resolve =>
|
||||
|
@ -238,6 +239,8 @@ function openURL(options) {
|
|||
index,
|
||||
active,
|
||||
currentWindow = true,
|
||||
newWindow = false,
|
||||
windowPosition
|
||||
} = options;
|
||||
|
||||
if (!url.includes('://')) {
|
||||
|
@ -271,6 +274,9 @@ function openURL(options) {
|
|||
if (emptyTab && !chromeInIncognito) {
|
||||
return activateTab(tab, {url, index}); // FIXME: should we move current empty tab?
|
||||
}
|
||||
if (newWindow) {
|
||||
return createWindow(Object.assign({url}, windowPosition));
|
||||
}
|
||||
const options = {url, index, active};
|
||||
// FF57+ supports openerTabId, but not in Android (indicated by the absence of chrome.windows)
|
||||
// FIXME: is it safe to assume that the current tab is the opener?
|
||||
|
|
Loading…
Reference in New Issue
Block a user