Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zulip/shared

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zulip/shared - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

65

js/typing_status.js
import _ from "underscore";
// See docs/subsystems/typing-indicators.md for details on typing indicators.
// The following constants are tuned to work with

@@ -17,18 +15,2 @@ // TYPING_STARTED_EXPIRY_PERIOD, which is what the other

/*
Our parent should pass in a worker object with the following
callbacks:
notify_server_start
notify_server_stop
get_recipient
get_current_time
is_valid_conversation
See typing.js for the implementations of the above. (Our
node tests also act as workers and will stub those functions
appropriately.)
*/
/** Exported only for tests. */

@@ -39,4 +21,4 @@ export const state = {};

export function initialize_state() {
state.current_recipient = undefined;
state.next_send_start_time = undefined;
state.current_recipient = null;
state.next_send_start_time = undefined;
state.idle_timer = undefined;

@@ -92,7 +74,31 @@ }

export function handle_text_input(worker) {
var new_recipient = worker.get_recipient();
/**
* Update our state machine, and the server as needed, on the user's typing status.
*
* This can and should be called frequently, on each keystroke. The
* implementation sends "still typing" notices at an appropriate throttled
* rate, and keeps a timer to send a "stopped typing" notice when the user
* hasn't typed for a few seconds.
*
* Zulip supports typing notifications only for PMs (both 1:1 and group); so
* composing a stream message should be treated like composing no message at
* all.
*
* Call with `new_recipient` of `null` when the user actively stops
* composing a message. If the user switches from one set of recipients to
* another, there's no need to call with `null` in between; the
* implementation tracks the change and behaves appropriately.
*
* See docs/subsystems/typing-indicators.md for detailed background on the
* typing indicators system.
*
* @param {*} worker Callbacks for reaching the real world. See typing.js
* for implementations.
* @param {*} new_recipient The users the PM being composed is addressed to,
* as a sorted array of user IDs; or `null` if no PM is being composed
* anymore.
*/
export function update(worker, new_recipient) {
var current_recipient = state.current_recipient;
if (current_recipient) {
if (current_recipient !== null) {
// We need to use _.isEqual for comparisons; === doesn't work

@@ -117,3 +123,3 @@ // on arrays.

if (!worker.is_valid_conversation(new_recipient)) {
if (new_recipient === null) {
// If we are not talking to somebody we care about,

@@ -131,10 +137,1 @@ // then there is no more action to take.

}
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);
}
}
{
"name": "@zulip/shared",
"version": "0.0.1",
"version": "0.0.2",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc