From 75f2c212c7a43fee54d6092b83d232691e404930 Mon Sep 17 00:00:00 2001 From: sudacode Date: Tue, 17 Mar 2026 19:49:46 -0700 Subject: [PATCH] refactor: centralize watch threshold constant Extract DEFAULT_MIN_WATCH_RATIO (0.85) into src/shared/watch-threshold.ts to replace the hardcoded ANILIST_UPDATE_MIN_WATCH_RATIO in main.ts. --- src/main.ts | 4 ++-- src/shared/watch-threshold.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 src/shared/watch-threshold.ts diff --git a/src/main.ts b/src/main.ts index 03ed9df..5a0448b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -129,6 +129,7 @@ import { openAnilistSetupInBrowser, rememberAnilistAttemptedUpdateKey, } from './main/runtime/domains/anilist'; +import { DEFAULT_MIN_WATCH_RATIO } from './shared/watch-threshold'; import { createApplyJellyfinMpvDefaultsHandler, createBuildApplyJellyfinMpvDefaultsMainDepsHandler, @@ -452,7 +453,6 @@ const ANILIST_SETUP_RESPONSE_TYPE = 'token'; const ANILIST_DEFAULT_CLIENT_ID = '36084'; const ANILIST_REDIRECT_URI = 'https://anilist.subminer.moe/'; const ANILIST_DEVELOPER_SETTINGS_URL = 'https://anilist.co/settings/developer'; -const ANILIST_UPDATE_MIN_WATCH_RATIO = 0.85; const ANILIST_UPDATE_MIN_WATCH_SECONDS = 10 * 60; const ANILIST_DURATION_RETRY_INTERVAL_MS = 15_000; const ANILIST_MAX_ATTEMPTED_UPDATE_KEYS = 1000; @@ -2365,7 +2365,7 @@ const { logInfo: (message) => logger.info(message), logWarn: (message) => logger.warn(message), minWatchSeconds: ANILIST_UPDATE_MIN_WATCH_SECONDS, - minWatchRatio: ANILIST_UPDATE_MIN_WATCH_RATIO, + minWatchRatio: DEFAULT_MIN_WATCH_RATIO, }, }); diff --git a/src/shared/watch-threshold.ts b/src/shared/watch-threshold.ts new file mode 100644 index 0000000..6993ebd --- /dev/null +++ b/src/shared/watch-threshold.ts @@ -0,0 +1 @@ +export const DEFAULT_MIN_WATCH_RATIO = 0.85;