Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
time_picker: Set minutes to zero in global time picker.
Joelutebe38730d0575
diff --git a/web/src/compose.js b/web/src/compose.jsindex 062f8e6e79f..6bc1906260d 100644--- a/web/src/compose.js+++ b/web/src/compose.js@@ -31,6 +31,7 @@ import * as stream_data from "./stream_data";import * as stream_settings_ui from "./stream_settings_ui";import * as sub_store from "./sub_store";import * as subscriber_api from "./subscriber_api";+import {get_timestamp_for_flatpickr} from "./timerender";import * as transmit from "./transmit";import * as ui_report from "./ui_report";import * as upload from "./upload";@@ -705,7 +706,7 @@ export function initialize() {flatpickr.show_flatpickr($(compose_click_target)[0],on_timestamp_selection,- new Date(),+ get_timestamp_for_flatpickr(),{// place the time picker above the icon and center it horizontallyposition: "above center",diff --git a/web/src/timerender.ts b/web/src/timerender.tsindex c0f4abfff19..03367cfd2a6 100644--- a/web/src/timerender.ts+++ b/web/src/timerender.ts@@ -355,9 +355,10 @@ export function get_timestamp_for_flatpickr(timestring: string): Date {// we use it to initialize the flatpickr instance.timestamp = parseISO(timestring);} finally {- // Otherwise, default to showing the current time.+ // Otherwise, default to showing the current time to the hour.if (!timestamp || !isValid(timestamp)) {timestamp = new Date();+ timestamp.setMinutes(0, 0);}}return timestamp;diff --git a/web/tests/timerender.test.js b/web/tests/timerender.test.jsindex afbf2a994b6..31050ed185c 100644--- a/web/tests/timerender.test.js+++ b/web/tests/timerender.test.js@@ -369,8 +369,10 @@ run_test("get_timestamp_for_flatpickr", () => {// Freeze time for testing.MockDate.set(date_2017.getTime());- // Invalid timestamps should show current time.- assert.equal(func("random str").valueOf(), Date.now());+ // Invalid timestamps should show current time on the hour.+ const date_without_minutes = new Date();+ date_without_minutes.setMinutes(0, 0);+ assert.equal(func("random str").valueOf(), date_without_minutes.getTime());// Valid ISO timestamps should return the timestamp.assert.equal(func(date_2017.toISOString()).valueOf(), date_2017.getTime());