From 00a9ecd118ae2eab8e1c1e77bc504f408f07b2e1 Mon Sep 17 00:00:00 2001 From: Dilan Date: Mon, 10 Jul 2023 19:09:29 -0700 Subject: [PATCH] fix account document load bug --- CHANGELOG.md | 1 + src/SaveDataManager.ts | 4 +++- src/utility/Utility.ts | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6af4ab..0d8ef26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ _2023-07-10_ +- Fixed a bug where account plans and schedules may not load and activate first even if they are the most recently edited. - Various UI updates, bug fixes, and other small changes. ### 2.6.0 diff --git a/src/SaveDataManager.ts b/src/SaveDataManager.ts index d2f0224..125e9f1 100644 --- a/src/SaveDataManager.ts +++ b/src/SaveDataManager.ts @@ -13,6 +13,7 @@ import { import { PlanData } from './types/PlanTypes'; import { ScheduleData } from './types/ScheduleTypes'; import { Mode } from './utility/Constants'; +import Utility from './utility/Utility'; const d = debug('save-data-manager'); const DEFAULT_SWITCHES: ReadUserOptions = { @@ -302,7 +303,8 @@ let SaveDataManager = { if (store != null) { if (store === 'true') val = true; else if (store === 'false') val = false; - else if (!isNaN(parseInt(store))) val = parseInt(store); + else if (Utility.isStringEntirelyANumber(store)) + val = parseInt(store); else val = store; } let switchId = keys[i].substring(7) as keyof ReadUserOptions; diff --git a/src/utility/Utility.ts b/src/utility/Utility.ts index dd6d12f..3391ae3 100644 --- a/src/utility/Utility.ts +++ b/src/utility/Utility.ts @@ -480,6 +480,10 @@ let Utility = { return start_time && end_time && meeting_days; }, + isStringEntirelyANumber: (str: string) => { + return /^\d+$/.test(str); + }, + friendlyEasterEgg: (text: string) => { if (text === 'naomi') { return ['Hmm?', "Wait what's going on?"];