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.
This commit is contained in:
roanster007 2024-02-03 20:00:57 +05:30 committed by Tim Abbott
parent d971b36026
commit 49e3e6da06
1 changed files with 8 additions and 1 deletions

View File

@ -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.