mirror of https://github.com/zulip/zulip.git
typing_status: Pull is_valid_conversation call up to top.
This is intended as a pure refactor, making the data flow clearer in preparation for further changes. In particular, this makes it manifest that the calls to `get_recipient` and `is_valid_conversation` don't depend on anything else that has happened during the call to `handle_text_input`. This is indeed a pure refactor because * is_valid_conversation itself has no side effects, either in the implementation in typing.js or in any reasonable implementation, so calling it sooner doesn't affect anything else; * if we do reach it, the only potentially-side-effecting code it's moving before is a call to `stop_last_notification`, and that in turn (with the existing, or any reasonable, implementation of `notify_server_stop`) has no effect on the data consulted by the implementation of `is_valid_conversation`.
This commit is contained in:
parent
453919bbc7
commit
07322d78a0
|
@ -89,8 +89,9 @@ export function maybe_ping_server(worker, recipient) {
|
|||
|
||||
export function handle_text_input(worker) {
|
||||
var new_recipient = worker.get_recipient();
|
||||
var current_recipient = state.current_recipient;
|
||||
var conversation_is_valid = worker.is_valid_conversation(new_recipient);
|
||||
|
||||
var current_recipient = state.current_recipient;
|
||||
if (current_recipient) {
|
||||
// We need to use _.isEqual for comparisons; === doesn't work
|
||||
// on arrays.
|
||||
|
@ -111,7 +112,7 @@ export function handle_text_input(worker) {
|
|||
stop_last_notification(worker);
|
||||
}
|
||||
|
||||
if (!worker.is_valid_conversation(new_recipient)) {
|
||||
if (!conversation_is_valid) {
|
||||
// If we are not talking to somebody we care about,
|
||||
// then there is no more action to take.
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue