Calculator UI simplification
This commit is contained in:
@@ -10,22 +10,22 @@ export class CalculatorService {
|
||||
private cachedStandardsConfigData: string | null = null;
|
||||
private lastRefreshedAt = 0;
|
||||
|
||||
private levelCalculator: LevelCalculator;
|
||||
private calculator: LevelCalculator;
|
||||
|
||||
constructor() {
|
||||
this.levelCalculator = new LevelCalculator(new Standards(DEFAULT_STANDARDS_DATA));
|
||||
this.calculator = new LevelCalculator(new Standards(DEFAULT_STANDARDS_DATA));
|
||||
}
|
||||
|
||||
calculate(player: Player, activityPerformances: ActivityPerformance[]) {
|
||||
this.refreshConfig({ onlyIfStale: true }).catch((err) => log.error({ err }, "failed to refresh calculator config"));
|
||||
return this.levelCalculator.calculate(player, activityPerformances);
|
||||
return this.calculator.calculate(player, activityPerformances);
|
||||
}
|
||||
|
||||
async getSelectedConfig(opt: { skipCache?: boolean } = {}): Promise<StandardsConfig> {
|
||||
if (!opt.skipCache) return this.levelCalculator.standards.cfg;
|
||||
if (!opt.skipCache) return this.calculator.standards.cfg;
|
||||
|
||||
await this.refreshConfig();
|
||||
return this.levelCalculator.standards.cfg;
|
||||
return this.calculator.standards.cfg;
|
||||
}
|
||||
|
||||
async selectConfig(id: string) {
|
||||
@@ -72,7 +72,7 @@ export class CalculatorService {
|
||||
const standardsConfigData = JSON.stringify(result.standards_config);
|
||||
if (standardsConfigData === this.cachedStandardsConfigData) return;
|
||||
|
||||
this.levelCalculator = new LevelCalculator(new Standards(DEFAULT_STANDARDS_DATA, result.standards_config));
|
||||
this.calculator = new LevelCalculator(new Standards(DEFAULT_STANDARDS_DATA, result.standards_config));
|
||||
this.cachedStandardsConfigData = standardsConfigData;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user