Merge pull request #1835 from Moonloard/replace-tab
Replace tab instead of creating a new one (#1765 #1704 #1590 #1837)
This commit is contained in:
commit
899476e81a
4 changed files with 27 additions and 12 deletions
|
@ -51,6 +51,11 @@ window.assignManager = {
|
|||
return !!syncEnabled;
|
||||
},
|
||||
|
||||
async getReplaceTabEnabled() {
|
||||
const { replaceTabEnabled } = await browser.storage.local.get("replaceTabEnabled");
|
||||
return !!replaceTabEnabled;
|
||||
},
|
||||
|
||||
getByUrlKey(siteStoreKey) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.area.get([siteStoreKey]).then((storageResponse) => {
|
||||
|
@ -233,9 +238,11 @@ window.assignManager = {
|
|||
return {};
|
||||
}
|
||||
}
|
||||
const replaceTabEnabled = await this.storageArea.getReplaceTabEnabled();
|
||||
const removeTab = backgroundLogic.NEW_TAB_PAGES.has(tab.url)
|
||||
|| (messageHandler.lastCreatedTab
|
||||
&& messageHandler.lastCreatedTab.id === tab.id);
|
||||
&& messageHandler.lastCreatedTab.id === tab.id)
|
||||
|| replaceTabEnabled;
|
||||
const openTabId = removeTab ? tab.openerTabId : tab.id;
|
||||
|
||||
if (!this.canceledRequests[tab.id]) {
|
||||
|
|
|
@ -16,25 +16,24 @@ async function requestPermissions() {
|
|||
|
||||
async function enableDisableSync() {
|
||||
const checkbox = document.querySelector("#syncCheck");
|
||||
if (checkbox.checked) {
|
||||
await browser.storage.local.set({syncEnabled: true});
|
||||
} else {
|
||||
await browser.storage.local.set({syncEnabled: false});
|
||||
}
|
||||
await browser.storage.local.set({syncEnabled: !!checkbox.checked});
|
||||
browser.runtime.sendMessage({ method: "resetSync" });
|
||||
}
|
||||
|
||||
async function enableDisableReplaceTab() {
|
||||
const checkbox = document.querySelector("#replaceTabCheck");
|
||||
await browser.storage.local.set({replaceTabEnabled: !!checkbox.checked});
|
||||
}
|
||||
|
||||
async function setupOptions() {
|
||||
const hasPermission = await browser.permissions.contains({permissions: ["bookmarks"]});
|
||||
const { syncEnabled } = await browser.storage.local.get("syncEnabled");
|
||||
const { replaceTabEnabled } = await browser.storage.local.get("replaceTabEnabled");
|
||||
if (hasPermission) {
|
||||
document.querySelector("#bookmarksPermissions").checked = true;
|
||||
}
|
||||
if (syncEnabled) {
|
||||
document.querySelector("#syncCheck").checked = true;
|
||||
} else {
|
||||
document.querySelector("#syncCheck").checked = false;
|
||||
}
|
||||
document.querySelector("#syncCheck").checked = !!syncEnabled;
|
||||
document.querySelector("#replaceTabCheck").checked = !!replaceTabEnabled;
|
||||
setupContainerShortcutSelects();
|
||||
}
|
||||
|
||||
|
@ -82,6 +81,7 @@ function resetOnboarding() {
|
|||
document.addEventListener("DOMContentLoaded", setupOptions);
|
||||
document.querySelector("#bookmarksPermissions").addEventListener( "change", requestPermissions);
|
||||
document.querySelector("#syncCheck").addEventListener( "change", enableDisableSync);
|
||||
document.querySelector("#replaceTabCheck").addEventListener( "change", enableDisableReplaceTab);
|
||||
document.querySelector("button").addEventListener("click", resetOnboarding);
|
||||
|
||||
for (let i=0; i < NUMBER_OF_KEYBOARD_SHORTCUTS; i++) {
|
||||
|
|
|
@ -20,6 +20,13 @@
|
|||
Enable Sync
|
||||
</label>
|
||||
<p><em>This setting allows you to sync your containers and site assignments across devices.</em></p>
|
||||
<h3>Tab behaviour:</h3>
|
||||
<label>
|
||||
<input type="checkbox" id="replaceTabCheck">
|
||||
Replace tab instead of creating a new one
|
||||
</label>
|
||||
<p><em>Replace the current tab if a page which is assigned to another container is opened (instead of keeping the current tab open).
|
||||
Opening tabs with middle mouse button is not affected.</em></p>
|
||||
<h3>Keyboard Shortcuts:</h3>
|
||||
<p><em>Edit which container is opened when using the numbered shortcuts.</em></p>
|
||||
<p><label>
|
||||
|
|
|
@ -87,7 +87,8 @@ const initializeWithTab = async (details = {
|
|||
"browserActionBadgesClicked": [],
|
||||
"onboarding-stage": 7,
|
||||
"achievements": [],
|
||||
"syncEnabled": true
|
||||
"syncEnabled": true,
|
||||
"replaceTabEnabled": false
|
||||
});
|
||||
window.browser.storage.local.set.resetHistory();
|
||||
window.browser.storage.sync.clear();
|
||||
|
|
Loading…
Add table
Reference in a new issue