mirror of https://github.com/zulip/zulip.git
js: Convert static/js/typing_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
e382389797
commit
b9e1d320e8
|
@ -156,7 +156,6 @@
|
||||||
"stream_list": false,
|
"stream_list": false,
|
||||||
"StripeCheckout": false,
|
"StripeCheckout": false,
|
||||||
"subs": false,
|
"subs": false,
|
||||||
"typing_events": false,
|
|
||||||
"ui": false,
|
"ui": false,
|
||||||
"ui_init": false,
|
"ui_init": false,
|
||||||
"unread": false,
|
"unread": false,
|
||||||
|
|
|
@ -88,7 +88,8 @@ const stream_events = {__esModule: true};
|
||||||
rewiremock("../../static/js/stream_events").with(stream_events);
|
rewiremock("../../static/js/stream_events").with(stream_events);
|
||||||
const submessage = {__esModule: true};
|
const submessage = {__esModule: true};
|
||||||
rewiremock("../../static/js/submessage").with(submessage);
|
rewiremock("../../static/js/submessage").with(submessage);
|
||||||
const typing_events = set_global("typing_events", {});
|
const typing_events = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/typing_events").with(typing_events);
|
||||||
const ui = set_global("ui", {});
|
const ui = set_global("ui", {});
|
||||||
const unread_ops = set_global("unread_ops", {});
|
const unread_ops = set_global("unread_ops", {});
|
||||||
const user_events = {__esModule: true};
|
const user_events = {__esModule: true};
|
||||||
|
|
|
@ -40,7 +40,8 @@ const message_view_header = {__esModule: true};
|
||||||
rewiremock("../../static/js/message_view_header").with(message_view_header);
|
rewiremock("../../static/js/message_view_header").with(message_view_header);
|
||||||
const top_left_corner = {__esModule: true};
|
const top_left_corner = {__esModule: true};
|
||||||
rewiremock("../../static/js/top_left_corner").with(top_left_corner);
|
rewiremock("../../static/js/top_left_corner").with(top_left_corner);
|
||||||
const typing_events = set_global("typing_events", {});
|
const typing_events = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/typing_events").with(typing_events);
|
||||||
const ui_util = {__esModule: true};
|
const ui_util = {__esModule: true};
|
||||||
rewiremock("../../static/js/ui_util").with(ui_util);
|
rewiremock("../../static/js/ui_util").with(ui_util);
|
||||||
const unread_ops = set_global("unread_ops", {});
|
const unread_ops = set_global("unread_ops", {});
|
||||||
|
|
|
@ -37,7 +37,6 @@ import "../templates";
|
||||||
import "../dropdown_list_widget";
|
import "../dropdown_list_widget";
|
||||||
import "../settings_profile_fields";
|
import "../settings_profile_fields";
|
||||||
import "../settings";
|
import "../settings";
|
||||||
import "../typing_events";
|
|
||||||
import "../ui_init";
|
import "../ui_init";
|
||||||
import "../emoji_picker";
|
import "../emoji_picker";
|
||||||
import "../compose_ui";
|
import "../compose_ui";
|
||||||
|
|
|
@ -27,7 +27,6 @@ declare let search_pill_widget: any;
|
||||||
declare let settings_profile_fields: any;
|
declare let settings_profile_fields: any;
|
||||||
declare let stream_list: any;
|
declare let stream_list: any;
|
||||||
declare let subs: any;
|
declare let subs: any;
|
||||||
declare let typing_events: any;
|
|
||||||
declare let ui: any;
|
declare let ui: any;
|
||||||
declare let unread: any;
|
declare let unread: any;
|
||||||
declare let unread_ops: any;
|
declare let unread_ops: any;
|
||||||
|
|
|
@ -23,6 +23,7 @@ const stream_data = require("./stream_data");
|
||||||
const stream_topic_history = require("./stream_topic_history");
|
const stream_topic_history = require("./stream_topic_history");
|
||||||
const top_left_corner = require("./top_left_corner");
|
const top_left_corner = require("./top_left_corner");
|
||||||
const topic_generator = require("./topic_generator");
|
const topic_generator = require("./topic_generator");
|
||||||
|
const typing_events = require("./typing_events");
|
||||||
const ui_util = require("./ui_util");
|
const ui_util = require("./ui_util");
|
||||||
const util = require("./util");
|
const util = require("./util");
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import * as stream_data from "./stream_data";
|
||||||
import * as stream_events from "./stream_events";
|
import * as stream_events from "./stream_events";
|
||||||
import * as stream_topic_history from "./stream_topic_history";
|
import * as stream_topic_history from "./stream_topic_history";
|
||||||
import * as submessage from "./submessage";
|
import * as submessage from "./submessage";
|
||||||
|
import * as typing_events from "./typing_events";
|
||||||
import * as user_events from "./user_events";
|
import * as user_events from "./user_events";
|
||||||
import * as user_groups from "./user_groups";
|
import * as user_groups from "./user_groups";
|
||||||
import * as user_status from "./user_status";
|
import * as user_status from "./user_status";
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
"use strict";
|
import render_typing_notifications from "../templates/typing_notifications.hbs";
|
||||||
|
|
||||||
const render_typing_notifications = require("../templates/typing_notifications.hbs");
|
import * as narrow_state from "./narrow_state";
|
||||||
|
import * as people from "./people";
|
||||||
const narrow_state = require("./narrow_state");
|
import * as typing_data from "./typing_data";
|
||||||
const people = require("./people");
|
|
||||||
const typing_data = require("./typing_data");
|
|
||||||
|
|
||||||
// See docs/subsystems/typing-indicators.md for details on typing indicators.
|
// See docs/subsystems/typing-indicators.md for details on typing indicators.
|
||||||
|
|
||||||
|
@ -46,7 +44,7 @@ function get_users_typing_for_narrow() {
|
||||||
return typing_data.get_all_typists();
|
return typing_data.get_all_typists();
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.render_notifications_for_narrow = function () {
|
export function render_notifications_for_narrow() {
|
||||||
const user_ids = get_users_typing_for_narrow();
|
const user_ids = get_users_typing_for_narrow();
|
||||||
const users_typing = user_ids.map((user_id) => people.get_by_user_id(user_id));
|
const users_typing = user_ids.map((user_id) => people.get_by_user_id(user_id));
|
||||||
if (users_typing.length === 0) {
|
if (users_typing.length === 0) {
|
||||||
|
@ -55,9 +53,9 @@ exports.render_notifications_for_narrow = function () {
|
||||||
$("#typing_notifications").html(render_typing_notifications({users: users_typing}));
|
$("#typing_notifications").html(render_typing_notifications({users: users_typing}));
|
||||||
$("#typing_notifications").show();
|
$("#typing_notifications").show();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.hide_notification = function (event) {
|
export function hide_notification(event) {
|
||||||
const recipients = event.recipients.map((user) => user.user_id);
|
const recipients = event.recipients.map((user) => user.user_id);
|
||||||
recipients.sort();
|
recipients.sort();
|
||||||
|
|
||||||
|
@ -66,11 +64,11 @@ exports.hide_notification = function (event) {
|
||||||
const removed = typing_data.remove_typist(recipients, event.sender.user_id);
|
const removed = typing_data.remove_typist(recipients, event.sender.user_id);
|
||||||
|
|
||||||
if (removed) {
|
if (removed) {
|
||||||
exports.render_notifications_for_narrow();
|
render_notifications_for_narrow();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.display_notification = function (event) {
|
export function display_notification(event) {
|
||||||
const recipients = event.recipients.map((user) => user.user_id);
|
const recipients = event.recipients.map((user) => user.user_id);
|
||||||
recipients.sort();
|
recipients.sort();
|
||||||
|
|
||||||
|
@ -79,10 +77,9 @@ exports.display_notification = function (event) {
|
||||||
|
|
||||||
typing_data.add_typist(recipients, sender_id);
|
typing_data.add_typist(recipients, sender_id);
|
||||||
|
|
||||||
exports.render_notifications_for_narrow();
|
render_notifications_for_narrow();
|
||||||
|
|
||||||
typing_data.kickstart_inbound_timer(recipients, TYPING_STARTED_EXPIRY_PERIOD, () => {
|
typing_data.kickstart_inbound_timer(recipients, TYPING_STARTED_EXPIRY_PERIOD, () => {
|
||||||
exports.hide_notification(event);
|
hide_notification(event);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
window.typing_events = exports;
|
|
||||||
|
|
Loading…
Reference in New Issue