Skip to content

Commit 7eb3bce

Browse files
Be more resilient when checking if the api key is present.
1 parent 04733d3 commit 7eb3bce

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

extension/changelog.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
{ "message": "Sidebar timer for OC 2.", "contributor": "DeKleineKobini" },
99
{ "message": "Fill Max for Item Market 2.0.", "contributor": "TheFoxMan" }
1010
],
11-
"fixes": [{ "message": "Split requests to TornPal if more scouts are needed than allowed in a single request.", "contributor": "DeKleineKobini" }],
11+
"fixes": [
12+
{ "message": "Split requests to TornPal if more scouts are needed than allowed in a single request.", "contributor": "DeKleineKobini" },
13+
{ "message": "Be more resilient when checking if the api key is present.", "contributor": "DeKleineKobini" }
14+
],
1215
"changes": [
1316
{ "message": "Disable OC1 timer when detecting OC 2 data.", "contributor": "DeKleineKobini" },
1417
{ "message": "Disable Faction OC timer when detecting OC 2 data.", "contributor": "DeKleineKobini" },

extension/scripts/global/functions/api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ function changeAPIKey(key) {
359359
}
360360

361361
function hasAPIData() {
362-
const hasKey = !!api.torn.key;
363-
const hasError = !!api.torn.error && !api.torn.error.includes("Backend error");
362+
const hasKey = !!api?.torn?.key;
363+
const hasError = !!api?.torn?.error && !api.torn.error.includes("Backend error");
364364
const hasUserdata = !!(userdata && Object.keys(userdata).length);
365365

366366
return hasKey && !hasError && hasUserdata;

0 commit comments

Comments
 (0)