From 291e16b124826d0e8ada513cda243fa6af12799f Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Wed, 9 Oct 2024 14:57:04 +1300 Subject: [PATCH] Revert to use local consts instead of config vars --- client/homebrew/utils/versionHistory.js | 12 ++---------- server/app.js | 3 +-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/client/homebrew/utils/versionHistory.js b/client/homebrew/utils/versionHistory.js index 49239bd94..9f026c41c 100644 --- a/client/homebrew/utils/versionHistory.js +++ b/client/homebrew/utils/versionHistory.js @@ -4,7 +4,7 @@ export const HISTORY_PREFIX = 'HOMEBREWERY-HISTORY'; export const HISTORY_SLOTS = 5; // History values in minutes -const DEFAULT_HISTORY_SAVE_DELAYS = { +const HISTORY_SAVE_DELAYS = { '0' : 0, '1' : 2, '2' : 10, @@ -16,10 +16,7 @@ const DEFAULT_HISTORY_SAVE_DELAYS = { const HB_DB = 'HOMEBREWERY-DB'; const HB_STORE = 'HISTORY'; -const DEFAULT_GARBAGE_COLLECT_DELAY = 28 * 24 * 60; - -let HISTORY_SAVE_DELAYS = DEFAULT_HISTORY_SAVE_DELAYS; -let GARBAGE_COLLECT_DELAY = DEFAULT_GARBAGE_COLLECT_DELAY; +const GARBAGE_COLLECT_DELAY = 28 * 24 * 60; function getKeyBySlot(brew, slot){ @@ -40,10 +37,6 @@ function parseBrewForStorage(brew, slot = 0) { expireAt : new Date() }; - if(global.config?.history?.HISTORY_SAVE_DELAYS){ - HISTORY_SAVE_DELAYS = global.config?.history?.HISTORY_SAVE_DELAYS; - } - archiveBrew.expireAt.setMinutes(archiveBrew.expireAt.getMinutes() + HISTORY_SAVE_DELAYS[slot]); const key = getKeyBySlot(brew, slot); @@ -129,7 +122,6 @@ export async function updateHistory(brew) { }; export async function versionHistoryGarbageCollection(){ - if(global.config?.history?.GARBAGE_COLLECT_DELAY != GARBAGE_COLLECT_DELAY) GARBAGE_COLLECT_DELAY = global.config?.history?.GARBAGE_COLLECT_DELAY; await IDB.entries(await createHBStore()) .then((entries)=>{ diff --git a/server/app.js b/server/app.js index 6dcabec12..90adde370 100644 --- a/server/app.js +++ b/server/app.js @@ -475,8 +475,7 @@ const renderPage = async (req, res)=>{ const configuration = { local : isLocalEnvironment, publicUrl : config.get('publicUrl') ?? '', - environment : nodeEnv, - history : config.get('historyConfig') ?? {} + environment : nodeEnv }; const props = { version : require('./../package.json').version,