From 49e3e6da062c6d9d9f336935493d3c3131066893 Mon Sep 17 00:00:00 2001 From: roanster007 Date: Sat, 3 Feb 2024 20:00:57 +0530 Subject: [PATCH] timerender: Fix get_timestamp_for_flatpickr when no parameter passed. Previously, when no parameter was passed to the get_timestamp_for_ flatpickr method, it would result in an uncaught exception. This is breaking the "Add global time" of compose bar. This can be avoided by doing an early return of current time to hour in case no string is passed. --- web/src/timerender.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/src/timerender.ts b/web/src/timerender.ts index 037be40a60..cf69deefd0 100644 --- a/web/src/timerender.ts +++ b/web/src/timerender.ts @@ -429,8 +429,15 @@ function get_current_time_to_hour(): Date { return timestamp; } -export function get_timestamp_for_flatpickr(timestring: string): Date { +export function get_timestamp_for_flatpickr(timestring?: string): Date { let timestamp; + + // timestring is undefined when first opening the picker from the + // compose box button. + if (timestring === undefined) { + return get_current_time_to_hour(); + } + try { // If there's already a valid time in the compose box, // we use it to initialize the flatpickr instance.