Add vote buttons to pill that open on click

This commit is contained in:
Ajay
2022-01-05 20:49:56 -05:00
parent a6a9b7dd8c
commit 8e964b40b3
12 changed files with 249 additions and 171 deletions

View File

@@ -21,6 +21,30 @@ async function wait<T>(condition: () => T | false, timeout = 5000, check = 100):
});
}
/**
* Gets the error message in a nice string
*
* @param {int} statusCode
* @returns {string} errorMessage
*/
function getErrorMessage(statusCode: number, responseText: string): string {
let errorMessage = "";
const postFix = (responseText ? "\n\n" + responseText : "");
if([400, 429, 409, 502, 503, 0].includes(statusCode)) {
//treat them the same
if (statusCode == 503) statusCode = 502;
errorMessage = chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode
+ "\n\n" + chrome.i18n.getMessage("statusReminder");
} else {
errorMessage = chrome.i18n.getMessage("connectionError") + statusCode;
}
return errorMessage + postFix;
}
export const GenericUtils = {
wait
wait,
getErrorMessage
}