mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 21:48:30 +00:00
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:
@@ -58,11 +58,6 @@ run_test('basics', () => {
|
|||||||
typing_status.update(worker, new_recipient);
|
typing_status.update(worker, new_recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
function call_stop() {
|
|
||||||
clear_events();
|
|
||||||
typing_status.stop(worker);
|
|
||||||
}
|
|
||||||
|
|
||||||
worker = {
|
worker = {
|
||||||
get_current_time: returns_time(5),
|
get_current_time: returns_time(5),
|
||||||
notify_server_start: notify_server_start,
|
notify_server_start: notify_server_start,
|
||||||
@@ -133,7 +128,7 @@ run_test('basics', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Call stop with nothing going on.
|
// Call stop with nothing going on.
|
||||||
call_stop();
|
call_handler(undefined);
|
||||||
assert.deepEqual(typing_status.state, {
|
assert.deepEqual(typing_status.state, {
|
||||||
next_send_start_time: undefined,
|
next_send_start_time: undefined,
|
||||||
idle_timer: undefined,
|
idle_timer: undefined,
|
||||||
@@ -163,7 +158,7 @@ run_test('basics', () => {
|
|||||||
assert(events.idle_callback);
|
assert(events.idle_callback);
|
||||||
|
|
||||||
// Explicitly stop alice.
|
// Explicitly stop alice.
|
||||||
call_stop();
|
call_handler(undefined);
|
||||||
assert.deepEqual(typing_status.state, {
|
assert.deepEqual(typing_status.state, {
|
||||||
next_send_start_time: undefined,
|
next_send_start_time: undefined,
|
||||||
idle_timer: undefined,
|
idle_timer: undefined,
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ exports.initialize = function () {
|
|||||||
// We send a stop-typing notification immediately when compose is
|
// We send a stop-typing notification immediately when compose is
|
||||||
// closed/cancelled
|
// closed/cancelled
|
||||||
$(document).on('compose_canceled.zulip compose_finished.zulip', function () {
|
$(document).on('compose_canceled.zulip compose_finished.zulip', function () {
|
||||||
typing_status.stop(worker);
|
typing_status.update(worker, undefined);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -130,12 +130,3 @@ export function update(worker, new_recipient) {
|
|||||||
actually_ping_server(worker, new_recipient, current_time);
|
actually_ping_server(worker, new_recipient, current_time);
|
||||||
start_or_extend_idle_timer(worker);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,5 +16,3 @@ declare export function update(
|
|||||||
worker: Worker,
|
worker: Worker,
|
||||||
new_recipient: RecipientUserIds | void,
|
new_recipient: RecipientUserIds | void,
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
declare export function stop(worker: Worker): void;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user