Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
js: Convert static/js/typing_data.js to ES6 module.
Anders Kaseorg2ee29972ac8e
diff --git a/.eslintrc.json b/.eslintrc.jsonindex 24a96bcab93..2f7c852e670 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -271,7 +271,6 @@"topic_list": false,"transmit": false,"typeahead_helper": false,- "typing_data": false,"typing_events": false,"ui": false,"ui_init": false,diff --git a/static/js/bundles/app.js b/static/js/bundles/app.jsindex da3a324a7f5..d41cf3dc8c4 100644--- a/static/js/bundles/app.js+++ b/static/js/bundles/app.js@@ -147,7 +147,6 @@ import "../admin";import "../message_view_header";import "../bot_data";import "../reactions";-import "../typing_data";import "../typing_events";import "../ui_init";import "../emoji_picker";diff --git a/static/js/global.d.ts b/static/js/global.d.tsindex cdf9565b032..14cb40bd706 100644--- a/static/js/global.d.ts+++ b/static/js/global.d.ts@@ -137,7 +137,6 @@ declare let topic_list: any;declare let top_left_corner: any;declare let transmit: any;declare let typeahead_helper: any;-declare let typing_data: any;declare let typing_events: any;declare let ui: any;declare let ui_report: any;diff --git a/static/js/typing_data.js b/static/js/typing_data.jsindex 56561199122..9862957969f 100644--- a/static/js/typing_data.js+++ b/static/js/typing_data.js@@ -1,8 +1,7 @@-"use strict";+import _ from "lodash";-const _ = require("lodash");+import * as util from "./util";-const util = require("./util");// See docs/subsystems/typing-indicators.md for details on typing indicators.const typist_dct = new Map();@@ -17,7 +16,7 @@ function get_key(group) {return ids.join(",");}-exports.add_typist = function (group, typist) {+export function add_typist(group, typist) {const key = get_key(group);const current = typist_dct.get(key) || [];typist = to_int(typist);@@ -25,9 +24,9 @@ exports.add_typist = function (group, typist) {current.push(typist);}typist_dct.set(key, util.sorted_ids(current));-};+}-exports.remove_typist = function (group, typist) {+export function remove_typist(group, typist) {const key = get_key(group);let current = typist_dct.get(key) || [];@@ -40,36 +39,34 @@ exports.remove_typist = function (group, typist) {typist_dct.set(key, current);return true;-};+}-exports.get_group_typists = function (group) {+export function get_group_typists(group) {const key = get_key(group);return typist_dct.get(key) || [];-};+}-exports.get_all_typists = function () {+export function get_all_typists() {let typists = [].concat(...Array.from(typist_dct.values()));typists = util.sorted_ids(typists);typists = _.sortedUniq(typists);return typists;-};+}// The next functions aren't pure data, but it is easy// enough to mock the setTimeout/clearTimeout functions.-exports.clear_inbound_timer = function (group) {+export function clear_inbound_timer(group) {const key = get_key(group);const timer = inbound_timer_dict.get(key);if (timer) {clearTimeout(timer);inbound_timer_dict.set(key, undefined);}-};+}-exports.kickstart_inbound_timer = function (group, delay, callback) {+export function kickstart_inbound_timer(group, delay, callback) {const key = get_key(group);- exports.clear_inbound_timer(group);+ clear_inbound_timer(group);const timer = setTimeout(callback, delay);inbound_timer_dict.set(key, timer);-};--window.typing_data = exports;+}diff --git a/static/js/typing_events.js b/static/js/typing_events.jsindex f916d5a1938..941352d7c95 100644--- a/static/js/typing_events.js+++ b/static/js/typing_events.js@@ -3,6 +3,7 @@const render_typing_notifications = require("../templates/typing_notifications.hbs");const people = require("./people");+const typing_data = require("./typing_data");// See docs/subsystems/typing-indicators.md for details on typing indicators.