Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
- fix error when deleting remote card with empty availableTeams
- fix search bar not working with empty restoreList
  • Loading branch information
nmarcopo committed May 30, 2020
1 parent 4f399e2 commit 99b4dce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Showdown Team Backup",
"version": "0.1.5",
"version": "0.1.6",
"description": "Backup teams from Pokemon Showdown across browsers!",
"permissions": ["activeTab", "declarativeContent", "storage", "identity", "identity.email"],
"background": {
Expand Down
15 changes: 11 additions & 4 deletions extension/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,13 @@ function deleteRemoteCard(teamKey, card) {

// Go through each combination and see if there's a match
for (let availableTeam of availableTeams.children) {
let availableTeamKey = hashTeam(availableTeam.querySelector("#teamJSON").innerText).toString();
let availableTeamKey = null;
try {
availableTeamKey = hashTeam(availableTeam.querySelector("#teamJSON").innerText).toString();
} catch {
// we only have the "no teams available" card pushed
break;
}
if (availableTeamKey === teamKey) {
// Enable button and change its color
enableButton(availableTeam.querySelector("#actionButton"), "btn-secondary", "btn-primary", "Backup", backupOnClick);
Expand Down Expand Up @@ -517,7 +523,7 @@ function disableDuplicates(init = false) {
restoreTeams.parentNode.replaceChild(moveDisabledToBottom(restoreTeams, query), restoreTeams)

startButtonListeners();
search();
showTeams(document.getElementById("searchLocalTeams").value);
}

// Runs when extension is loaded
Expand All @@ -526,10 +532,11 @@ function loadTeamsInShowdown() {
chrome.tabs.executeScript(null, {
file: "getAvailableTeams.js"
}, function (ret) {
document.getElementById("searchLocalTeams").value = localStorage.getItem("localSearchTerm");
displayTeams(ret[0], "localTeams");
restoreList("init");
startButtonListeners();
document.getElementById("searchLocalTeams").value = localStorage.getItem("localSearchTerm");
search();
});
}

Expand Down Expand Up @@ -572,5 +579,5 @@ document.getElementById("clearSearchButton").addEventListener("click", function
console.log("clearing");
let searchbox = document.getElementById("searchLocalTeams");
searchbox.value = "";
search(searchbox.value);
showTeams(searchbox.value);
}, false);

0 comments on commit 99b4dce

Please sign in to comment.