From 37351402f815e43991f91d0a1aa2860be9651be1 Mon Sep 17 00:00:00 2001 From: phroggster Date: Fri, 27 Sep 2024 17:33:39 -0500 Subject: [PATCH] Better issue2801 Conditionals - currency-access.ts should also catch nulls, while 0's are OK. - currency-manager.ts is much more concise with a boolean nullish. - As-is currency.service.js... - ... which also had two lint warnings in it that got buffed out. --- src/backend/currency/currency-access.ts | 2 +- src/backend/currency/currency-manager.ts | 2 +- src/gui/app/services/currency.service.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/currency/currency-access.ts b/src/backend/currency/currency-access.ts index 56659e6b3..233e1437f 100644 --- a/src/backend/currency/currency-access.ts +++ b/src/backend/currency/currency-access.ts @@ -52,7 +52,7 @@ class CurrencyAccess { let issue2801 = false; const cache = db.getData("/"); Object.keys(cache).forEach((currencyId) => { - if (cache[currencyId].offline === "") { + if (cache[currencyId].offline === null || cache[currencyId].offline === "") { issue2801 = true; cache[currencyId].offline = undefined; } diff --git a/src/backend/currency/currency-manager.ts b/src/backend/currency/currency-manager.ts index 6e83b95d2..1e4458b53 100644 --- a/src/backend/currency/currency-manager.ts +++ b/src/backend/currency/currency-manager.ts @@ -263,7 +263,7 @@ class CurrencyManager { for (const currency of currencies) { let basePayout = currency.payout; if (!connectionManager.streamerIsOnline()) { - if (currency.offline == null || currency.offline === 0) { + if (!currency.offline) { continue; } diff --git a/src/gui/app/services/currency.service.js b/src/gui/app/services/currency.service.js index 56acf059d..9d137f794 100644 --- a/src/gui/app/services/currency.service.js +++ b/src/gui/app/services/currency.service.js @@ -107,12 +107,12 @@ ipcRenderer.send("refreshCurrencyCommands", {"action": "delete", "currency": currency}); }; - backendCommunicator.on("import-currency", currency => { + backendCommunicator.on("import-currency", (currency) => { if (currency == null || currency.id == null) { return; } - if (currency.offline === "") { + if (!currency.offline) { currency.offline = undefined; } @@ -123,7 +123,7 @@ } }); - backendCommunicator.on("remove-currency", currency => { + backendCommunicator.on("remove-currency", (currency) => { service.deleteCurrency(currency); });