Fixed error messages not working. Added message for error 503 and 0.

This commit is contained in:
Ajay Ramachandran
2019-11-23 12:26:24 -05:00
parent 108aac0e79
commit 6790952f86
3 changed files with 15 additions and 4 deletions

View File

@@ -262,5 +262,8 @@
}, },
"keybindDescriptionComplete": { "keybindDescriptionComplete": {
"message": "The keybind has been set to: " "message": "The keybind has been set to: "
},
"0": {
"message": "Connection Timeout. Check your internet connection. If your internet is working, the server is probably overloaded or down."
} }
} }

View File

@@ -1041,8 +1041,11 @@ function sendSubmitMessage(){
document.getElementById("submitButton").style.animation = "unset"; document.getElementById("submitButton").style.animation = "unset";
document.getElementById("submitImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png"); document.getElementById("submitImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
if([400,429,409,502].includes(response.statusCode)) { if([400, 429, 409, 502, 0].includes(response.statusCode)) {
alert(chrome.i18n.getMessage(response.statusCode)); //treat them the same
if (response.statusCode == 503) response.statusCode = 502;
alert(chrome.i18n.getMessage(response.statusCode + ""));
} else { } else {
alert(chrome.i18n.getMessage("connectionError") + response.statusCode); alert(chrome.i18n.getMessage("connectionError") + response.statusCode);
} }

View File

@@ -811,8 +811,11 @@ function runThePopup() {
} else { } else {
let errorMessage = ""; let errorMessage = "";
if([400,429,409,502].includes(response.statusCode)) { if([400, 429, 409, 502, 0].includes(response.statusCode)) {
errorMessage = chrome.i18n.getMessage(response.statusCode); //treat them the same
if (response.statusCode == 503) response.statusCode = 502;
errorMessage = chrome.i18n.getMessage(response.statusCode + "");
} else { } else {
errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode; errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode;
} }
@@ -1109,8 +1112,10 @@ function runThePopup() {
type: type, type: type,
UUID: UUID UUID: UUID
}, function(response) { }, function(response) {
console.log(response)
if (response != undefined) { if (response != undefined) {
//see if it was a success or failure //see if it was a success or failure
console.log(response)
if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) { if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) {
//success (treat rate limits as a success) //success (treat rate limits as a success)
addVoteMessage(chrome.i18n.getMessage("voted"), UUID) addVoteMessage(chrome.i18n.getMessage("voted"), UUID)