From 471c8af23e190b5d0dffef646ca8a9b06ac977a1 Mon Sep 17 00:00:00 2001 From: jamesb Date: Sat, 2 Oct 2021 11:54:00 +0100 Subject: [PATCH] - Fixed: Dropdown dates setting bugs. --- data.json | 3 ++- src/views/settings-tab.ts | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/data.json b/data.json index 5abed0b..39c4ca8 100644 --- a/data.json +++ b/data.json @@ -17,6 +17,7 @@ "today": "today", "tomorrow": "tomorrow", "in two days": "in two days", - "next week": "next week" + "next week": "next week", + "in two weeks": "in two weeks" } } \ No newline at end of file diff --git a/src/views/settings-tab.ts b/src/views/settings-tab.ts index 57e995c..47820a4 100644 --- a/src/views/settings-tab.ts +++ b/src/views/settings-tab.ts @@ -122,9 +122,9 @@ export class IWSettingsTab extends PluginSettingTab { return; } - const validDates = inputDates - .filter(([_, date]) => date != null && date.date) - .map(([s, _]) => s); + const validDates: string[] = inputDates + .filter(([_, date]: [string, any]) => date != null && date.date) + .map(([s, _]: [string, Date]) => s); if (inputDates.length !== validDates.length) { LogTo.Debug( @@ -134,13 +134,13 @@ export class IWSettingsTab extends PluginSettingTab { ); } - const dateOptionsRecord: Record< - string, - string - > = validDates.reduce( - (acc: Record, x: string) => (acc[x] = x), - {} - ); + const dateOptionsRecord: Record = validDates + .reduce((acc, x) => + { + acc[x] = x; + return acc; + }, {} as Record); + LogTo.Debug( "Setting dropdown date options to " + JSON.stringify(dateOptionsRecord)