From 0d553e8ea6e1243d9f88a185221c6c043532af37 Mon Sep 17 00:00:00 2001 From: DrakiaXYZ Date: Thu, 18 Apr 2024 07:55:39 +0000 Subject: [PATCH] Move setting of the `generated` bools to inside the cache methods (!298) Also make `generateDynamicPrices` public to match the static method, and allow mods to refresh the cache Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/298 Co-authored-by: DrakiaXYZ Co-committed-by: DrakiaXYZ --- project/src/services/RagfairPriceService.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/project/src/services/RagfairPriceService.ts b/project/src/services/RagfairPriceService.ts index ad684c47..6c3e578b 100644 --- a/project/src/services/RagfairPriceService.ts +++ b/project/src/services/RagfairPriceService.ts @@ -56,13 +56,11 @@ export class RagfairPriceService implements OnLoad if (!this.generatedStaticPrices) { this.generateStaticPrices(); - this.generatedStaticPrices = true; } if (!this.generatedDynamicPrices) { this.generateDynamicPrices(); - this.generatedDynamicPrices = true; } } @@ -84,14 +82,18 @@ export class RagfairPriceService implements OnLoad { this.prices.static[item._id] = Math.round(this.handbookHelper.getTemplatePrice(item._id)); } + + this.generatedStaticPrices = true; } /** * Create a dictionary and store prices from prices.json in it */ - protected generateDynamicPrices(): void + public generateDynamicPrices(): void { Object.assign(this.prices.dynamic, this.databaseServer.getTables().templates.prices); + + this.generatedDynamicPrices = true; } /**