Skip to content

Commit

Permalink
typing_status: Fold stop into main method update.
Browse files Browse the repository at this point in the history
It'd already been the case for some while that calling `stop` had the
same effect as calling `update` (previously `handle_text_input`) with
a falsy recipient.  With the API changes in the previous few commits,
this becomes quite natural to make explicit in the API.
  • Loading branch information
gnprice committed Oct 24, 2019
1 parent e639b0a commit a191890
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 19 deletions.
9 changes: 2 additions & 7 deletions frontend_tests/node_tests/typing_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ run_test('basics', () => {
typing_status.update(worker, new_recipient);
}

function call_stop() {
clear_events();
typing_status.stop(worker);
}

worker = {
get_current_time: returns_time(5),
notify_server_start: notify_server_start,
Expand Down Expand Up @@ -133,7 +128,7 @@ run_test('basics', () => {
});

// Call stop with nothing going on.
call_stop();
call_handler(undefined);
assert.deepEqual(typing_status.state, {
next_send_start_time: undefined,
idle_timer: undefined,
Expand Down Expand Up @@ -163,7 +158,7 @@ run_test('basics', () => {
assert(events.idle_callback);

// Explicitly stop alice.
call_stop();
call_handler(undefined);
assert.deepEqual(typing_status.state, {
next_send_start_time: undefined,
idle_timer: undefined,
Expand Down
2 changes: 1 addition & 1 deletion static/js/typing.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports.initialize = function () {
// We send a stop-typing notification immediately when compose is
// closed/cancelled
$(document).on('compose_canceled.zulip compose_finished.zulip', function () {
typing_status.stop(worker);
typing_status.update(worker, undefined);
});
};

Expand Down
9 changes: 0 additions & 9 deletions static/shared/js/typing_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,3 @@ export function update(worker, new_recipient) {
actually_ping_server(worker, new_recipient, current_time);
start_or_extend_idle_timer(worker);
}

export function stop(worker) {
// We get this if somebody closes the compose box, but
// it doesn't necessarily mean we had typing indicators
// active before this.
if (state.current_recipient) {
stop_last_notification(worker);
}
}
2 changes: 0 additions & 2 deletions static/shared/js/typing_status.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ declare export function update(
worker: Worker,
new_recipient: RecipientUserIds | void,
): void;

declare export function stop(worker: Worker): void;

0 comments on commit a191890

Please sign in to comment.