Skip to content

Commit

Permalink
Better issue2801 Conditionals
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
phroggster committed Sep 27, 2024
1 parent 48eb0ba commit 3735140
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/backend/currency/currency-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/currency/currency-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/gui/app/services/currency.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -123,7 +123,7 @@
}
});

backendCommunicator.on("remove-currency", currency => {
backendCommunicator.on("remove-currency", (currency) => {
service.deleteCurrency(currency);
});

Expand Down

0 comments on commit 3735140

Please sign in to comment.