Skip to content

Commit

Permalink
typing: Fix early read of page_params.
Browse files Browse the repository at this point in the history
For spectators,
page_params.server_typing_started_wait_period_milliseconds and
page_params.server_typing_stopped_wait_period_milliseconds have not
been initialized yet at module load time.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
  • Loading branch information
andersk authored and timabbott committed Jan 2, 2024
1 parent 80432c8 commit 45c8dcc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions web/src/typing.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ import {user_settings} from "./user_settings";
// when we are typing. For the inbound side see typing_events.js.
// See docs/subsystems/typing-indicators.md for more details.

// How frequently 'start' notifications are sent to extend
// the expiry of active typing indicators.
const typing_started_wait_period = page_params.server_typing_started_wait_period_milliseconds;
// How long after someone stops editing in the compose box
// do we send a 'stop' notification.
const typing_stopped_wait_period = page_params.server_typing_stopped_wait_period_milliseconds;

function send_typing_notification_ajax(data) {
channel.post({
url: "/json/typing",
Expand Down Expand Up @@ -121,14 +114,19 @@ export function initialize() {
typing_status.update(
worker,
new_recipient,
typing_started_wait_period,
typing_stopped_wait_period,
page_params.server_typing_started_wait_period_milliseconds,
page_params.server_typing_stopped_wait_period_milliseconds,
);
});

// We send a stop-typing notification immediately when compose is
// closed/cancelled
$(document).on("compose_canceled.zulip compose_finished.zulip", () => {
typing_status.update(worker, null, typing_started_wait_period, typing_stopped_wait_period);
typing_status.update(
worker,
null,
page_params.server_typing_started_wait_period_milliseconds,
page_params.server_typing_stopped_wait_period_milliseconds,
);
});
}

0 comments on commit 45c8dcc

Please sign in to comment.