Skip to content

Commit

Permalink
Fixed issue in option page that allowed login on unsaved configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiRigal committed Oct 13, 2021
1 parent b11c45d commit 54e145b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Yape",
"version": "0.0.5",
"version": "0.0.6",
"description": "Extension for PyLoad to easily monitor and add downloads",
"permissions": ["activeTab", "storage", "contextMenus", "scripting"],
"host_permissions": ["http://*/", "https://*/"],
Expand Down
18 changes: 17 additions & 1 deletion options.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function getProtocol() {
return useHTTPSInput.checked ? 'https' : 'http';
}

function updateLoggedInStatus() {
function updateLoggedInStatus(callback) {
saveButton.disabled = true;
loginStatusOKDiv.hidden = true;
loginStatusKODiv.hidden = true;
Expand All @@ -57,6 +57,7 @@ function updateLoggedInStatus() {
loginStatusKODiv.hidden = loggedIn;
loginButton.hidden = loggedIn;
saveButton.disabled = false;
if (callback) callback();
});
}

Expand All @@ -81,6 +82,17 @@ function requestPermission(callback) {
});
}

function requireSaving() {
if (serverIpInput.value === serverIp && parseInt(serverPortInput.value) === parseInt(serverPort) && useHTTPSInput.checked === (serverProtocol === 'https')) {
updateLoggedInStatus();
} else {
saveButton.disabled = false;
loginStatusOKDiv.hidden = true;
loginStatusKODiv.hidden = true;
loginButton.hidden = true;
}
}

saveButton.onclick = function(ev) {
setOrigin(serverIpInput.value, serverPortInput.value, getProtocol(), function() {
requestPermission(function(granted) {
Expand Down Expand Up @@ -110,5 +122,9 @@ pullStoredData(function() {
serverPortInput.value = serverPort;
useHTTPSInput.checked = serverProtocol === 'https';

serverIpInput.oninput = requireSaving;
serverPortInput.oninput = requireSaving;
useHTTPSInput.oninput = requireSaving;

updateLoggedInStatus();
});

0 comments on commit 54e145b

Please sign in to comment.