(proxyInfo)
| 1718 | } |
| 1719 | |
| 1720 | async updateProxyDependentUi(proxyInfo) { |
| 1721 | const mozillaVpnProxyLocationAvailable = (proxy) => { |
| 1722 | return typeof(proxy) !== "undefined" && typeof(proxy.countryCode) !== "undefined" && typeof(proxy.cityName) !== "undefined"; |
| 1723 | }; |
| 1724 | |
| 1725 | const mozillaVpnProxyIsEnabled = (proxy) => { |
| 1726 | return typeof(proxy) !== "undefined" && typeof(proxy.mozProxyEnabled) !== "undefined" && proxy.mozProxyEnabled === true; |
| 1727 | }; |
| 1728 | |
| 1729 | this.switch.checked = mozillaVpnProxyIsEnabled(proxyInfo); |
| 1730 | this.updateProxyInputs(proxyInfo); |
| 1731 | this.enableDisableProxyButtons(); |
| 1732 | |
| 1733 | const mozillaVpnConnected = await browser.runtime.sendMessage({ method: "MozillaVPN_getConnectionStatus" }); |
| 1734 | if ( |
| 1735 | !proxyInfo || |
| 1736 | !mozillaVpnProxyLocationAvailable(proxyInfo) || |
| 1737 | !mozillaVpnConnected |
| 1738 | ) { |
| 1739 | // Hide server location button |
| 1740 | this.currentServerButton.classList.add("hidden"); |
| 1741 | this.classList.remove("show-server-button"); |
| 1742 | } else { |
| 1743 | // Unhide server location button |
| 1744 | this.currentServerButton.style.display = "flex"; |
| 1745 | this.currentServerButton.classList.remove("hidden"); |
| 1746 | this.classList.add("show-server-button"); |
| 1747 | } |
| 1748 | |
| 1749 | // Populate inputs and server button with current or previously stored mozilla vpn proxy |
| 1750 | if(proxyInfo && mozillaVpnProxyLocationAvailable(proxyInfo)) { |
| 1751 | this.currentCountryFlag.style.backgroundImage = `url("./img/flags/${proxyInfo.countryCode.toUpperCase()}.png")`; |
| 1752 | this.currentCountryFlag.style.backgroundImage = proxyInfo.countryCode + ".png"; |
| 1753 | this.currentCityName.textContent = proxyInfo.cityName; |
| 1754 | this.countryCode = proxyInfo.countryCode; |
| 1755 | } |
| 1756 | } |
| 1757 | |
| 1758 | expandUi() { |
| 1759 | this.classList.add("expanded"); |
no test coverage detected