typing_status: Fold stop into main method update.

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.
This commit is contained in:
Greg Price
2019-10-21 17:44:14 -07:00
parent e639b0a6f8
commit a191890213
4 changed files with 3 additions and 19 deletions

View File

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

View File

@@ -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);
});
};

View File

@@ -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);
}
}

View File

@@ -16,5 +16,3 @@ declare export function update(
worker: Worker,
new_recipient: RecipientUserIds | void,
): void;
declare export function stop(worker: Worker): void;