From 93e7333ed4fb50272463edcd84af380f7edbe458 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 7 Aug 2024 17:16:04 +0200 Subject: [PATCH 1/2] Nit: Make The Popup Follow the Active Tab Context --- src/ui/browserAction/popupPage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ui/browserAction/popupPage.js b/src/ui/browserAction/popupPage.js index 9bfc056..293cb53 100644 --- a/src/ui/browserAction/popupPage.js +++ b/src/ui/browserAction/popupPage.js @@ -51,8 +51,16 @@ export class BrowserActionPopup extends LitElement { super(); this.pageURL = null; this._siteContext = null; + this.updatePage(); + browser.tabs.onUpdated.addListener(() => this.updatePage()); + browser.tabs.onActivated.addListener(() => this.updatePage()); + vpnController.state.subscribe((s) => (this.vpnState = s)); + } + updatePage() { Utils.getCurrentTab().then(async (tab) => { if (!Utils.isValidForProxySetting(tab.url)) { + this.pageURL = null; + this._siteContext = null; return; } const hostname = Utils.getFormattedHostname(tab.url); @@ -61,8 +69,8 @@ export class BrowserActionPopup extends LitElement { this._siteContext = proxyHandler.siteContexts.value.get(this.pageURL); } }); - vpnController.state.subscribe((s) => (this.vpnState = s)); } + connectedCallback() { super.connectedCallback(); } From fd9db136544fbc088bdeb1bac5edc9ef50c172e5 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 21 Aug 2024 22:47:38 +0200 Subject: [PATCH 2/2] Address feedback --- src/ui/browserAction/popupPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/browserAction/popupPage.js b/src/ui/browserAction/popupPage.js index 293cb53..5e2b166 100644 --- a/src/ui/browserAction/popupPage.js +++ b/src/ui/browserAction/popupPage.js @@ -51,10 +51,10 @@ export class BrowserActionPopup extends LitElement { super(); this.pageURL = null; this._siteContext = null; - this.updatePage(); browser.tabs.onUpdated.addListener(() => this.updatePage()); browser.tabs.onActivated.addListener(() => this.updatePage()); vpnController.state.subscribe((s) => (this.vpnState = s)); + this.updatePage(); } updatePage() { Utils.getCurrentTab().then(async (tab) => {