Skip to content

Commit

Permalink
disable private fields
Browse files Browse the repository at this point in the history
  • Loading branch information
stephtr committed Oct 27, 2024
1 parent 1aa117c commit 0ec4ffe
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions website/src/lib/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export class Calculator {

settings = new Settings();

#isLoaded = false;
private _isLoaded = false;

get isLoaded() {
return this.#isLoaded;
return this._isLoaded;
}

private loadedListeners: Array<() => void> = [];
Expand Down Expand Up @@ -109,15 +109,15 @@ export class Calculator {
};
}

#pendingCalculationOnceLoaded: string | null = null;
private pendingCalculationOnceLoaded: string | null = null;

submitCalculation(input: string) {
const isSetCommand = input.startsWith('set ');
if (!isSetCommand) {
this.submittedListeners.forEach((l) => l(input));
}
if (!this.isLoaded) {
this.#pendingCalculationOnceLoaded = input;
this.pendingCalculationOnceLoaded = input;
return;
}

Expand All @@ -128,17 +128,17 @@ export class Calculator {
}
}

#pendingCurrencyData: CurrencyData | null = null;
private pendingCurrencyData: CurrencyData | null = null;

#lastCurrencyUpdateDate: number = 0;
private lastCurrencyUpdateDate: number = 0;

updateCurrencyData(data: CurrencyData) {
const newDate = +new Date(data.date);
if (this.#lastCurrencyUpdateDate >= newDate) return;
this.#lastCurrencyUpdateDate = newDate;
if (this.lastCurrencyUpdateDate >= newDate) return;
this.lastCurrencyUpdateDate = newDate;

if (!this.isLoaded) {
this.#pendingCurrencyData = data;
this.pendingCurrencyData = data;
return;
}
updateCurrencyValues(
Expand All @@ -155,18 +155,18 @@ export class Calculator {
if (typeof window !== 'undefined') {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
initializeCalculationModule().then(() => {
this.#isLoaded = true;
this._isLoaded = true;

this.settings.apply();

if (this.#pendingCurrencyData) {
this.updateCurrencyData(this.#pendingCurrencyData);
this.#pendingCurrencyData = null;
if (this.pendingCurrencyData) {
this.updateCurrencyData(this.pendingCurrencyData);
this.pendingCurrencyData = null;
}

if (this.#pendingCalculationOnceLoaded) {
this.submitCalculation(this.#pendingCalculationOnceLoaded);
this.#pendingCalculationOnceLoaded = null;
if (this.pendingCalculationOnceLoaded) {
this.submitCalculation(this.pendingCalculationOnceLoaded);
this.pendingCalculationOnceLoaded = null;
}
this.loadedListeners.forEach((l) => l());
});
Expand Down

0 comments on commit 0ec4ffe

Please sign in to comment.