Fixed Switch Instance not working from context menu https://github.com/libredirect/libredirect/issues/609

This commit is contained in:
ManeraKai 2023-02-01 23:07:52 +03:00
parent a3b2f52836
commit 7ee9fb21ea
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337

View File

@ -77,7 +77,7 @@ browser.tabs.onRemoved.addListener(tabId => {
}) })
browser.commands.onCommand.addListener(async command => { browser.commands.onCommand.addListener(async command => {
if (command === "switchInstance") { if (command == "switchInstance") {
const newUrl = await servicesHelper.switchInstance() const newUrl = await servicesHelper.switchInstance()
if (newUrl) browser.tabs.update({ url: newUrl }) if (newUrl) browser.tabs.update({ url: newUrl })
} }
@ -117,7 +117,8 @@ browser.contextMenus.create({
browser.contextMenus.onClicked.addListener((info, tab) => { browser.contextMenus.onClicked.addListener((info, tab) => {
return new Promise(async resolve => { return new Promise(async resolve => {
if (info.menuItemId == 'switchInstance') { if (info.menuItemId == 'switchInstance') {
servicesHelper.switchInstance() const newUrl = await servicesHelper.switchInstance()
if (newUrl) browser.tabs.update({ url: newUrl })
} }
else if (info.menuItemId == 'settings') { else if (info.menuItemId == 'settings') {
browser.runtime.openOptionsPage() browser.runtime.openOptionsPage()