Skip to content

Commit

Permalink
timerender: Fix get_timestamp_for_flatpickr when no parameter passed.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
roanster007 authored and timabbott committed Feb 5, 2024
1 parent d971b36 commit 49e3e6d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion web/src/timerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 49e3e6d

Please sign in to comment.