mirror of
https://github.com/zulip/zulip.git
synced 2025-10-26 09:34:02 +00:00
js: Convert static/js/stream_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
f47090136d
commit
72ffb33589
@@ -213,7 +213,6 @@
|
||||
"settings_users": false,
|
||||
"starred_messages": false,
|
||||
"stream_edit": false,
|
||||
"stream_events": false,
|
||||
"stream_list": false,
|
||||
"stream_popover": false,
|
||||
"StripeCheckout": false,
|
||||
|
||||
@@ -60,7 +60,8 @@ const settings_user_groups = set_global("settings_user_groups", {});
|
||||
const settings_users = set_global("settings_users", {});
|
||||
const stream_data = {__esModule: true};
|
||||
rewiremock("../../static/js/stream_data").with(stream_data);
|
||||
const stream_events = set_global("stream_events", {});
|
||||
const stream_events = {__esModule: true};
|
||||
rewiremock("../../static/js/stream_events").with(stream_events);
|
||||
const submessage = {__esModule: true};
|
||||
rewiremock("../../static/js/submessage").with(submessage);
|
||||
const typing_events = set_global("typing_events", {});
|
||||
|
||||
@@ -15,7 +15,8 @@ const test_user = events.test_user;
|
||||
|
||||
const compose_fade = {__esModule: true};
|
||||
rewiremock("../../static/js/compose_fade").with(compose_fade);
|
||||
const stream_events = set_global("stream_events", {});
|
||||
const stream_events = {__esModule: true};
|
||||
rewiremock("../../static/js/stream_events").with(stream_events);
|
||||
const subs = set_global("subs", {});
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
@@ -93,7 +93,7 @@ const setup = () => {
|
||||
throw new Error("update error");
|
||||
},
|
||||
});
|
||||
set_global("stream_events", {
|
||||
rewiremock("../../static/js/stream_events").with({
|
||||
update_property() {
|
||||
throw new Error("subs update error");
|
||||
},
|
||||
|
||||
@@ -25,7 +25,6 @@ import "../message_list";
|
||||
import "../narrow";
|
||||
import "../reload";
|
||||
import "../compose_actions";
|
||||
import "../stream_events";
|
||||
import "../stream_edit";
|
||||
import "../subs";
|
||||
import "../message_edit";
|
||||
|
||||
1
static/js/global.d.ts
vendored
1
static/js/global.d.ts
vendored
@@ -86,7 +86,6 @@ declare let settings_user_groups: any;
|
||||
declare let settings_users: any;
|
||||
declare let starred_messages: any;
|
||||
declare let stream_edit: any;
|
||||
declare let stream_events: any;
|
||||
declare let stream_list: any;
|
||||
declare let stream_popover: any;
|
||||
declare let subs: any;
|
||||
|
||||
@@ -11,6 +11,7 @@ import * as people from "./people";
|
||||
import * as reload from "./reload";
|
||||
import * as settings_config from "./settings_config";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as stream_events from "./stream_events";
|
||||
import * as stream_topic_history from "./stream_topic_history";
|
||||
import * as submessage from "./submessage";
|
||||
import * as user_groups from "./user_groups";
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const color_data = require("./color_data");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const peer_data = require("./peer_data");
|
||||
const stream_color = require("./stream_color");
|
||||
const stream_data = require("./stream_data");
|
||||
const stream_muting = require("./stream_muting");
|
||||
import * as color_data from "./color_data";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as peer_data from "./peer_data";
|
||||
import * as stream_color from "./stream_color";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as stream_muting from "./stream_muting";
|
||||
|
||||
// In theory, this function should apply the account-level defaults,
|
||||
// however, they are only called after a manual override, so
|
||||
@@ -17,7 +15,7 @@ function update_stream_setting(sub, value, setting) {
|
||||
sub[setting] = value;
|
||||
}
|
||||
|
||||
exports.update_property = function (stream_id, property, value, other_values) {
|
||||
export function update_property(stream_id, property, value, other_values) {
|
||||
const sub = stream_data.get_sub_by_id(stream_id);
|
||||
if (sub === undefined) {
|
||||
// This isn't a stream we know about, so ignore it.
|
||||
@@ -76,12 +74,12 @@ exports.update_property = function (stream_id, property, value, other_values) {
|
||||
value,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Add yourself to a stream we already know about client-side.
|
||||
// It's likely we should be passing in the full sub object from the caller/backend,
|
||||
// but for now we just pass in the subscribers and color (things likely to be different).
|
||||
exports.mark_subscribed = function (sub, subscribers, color) {
|
||||
export function mark_subscribed(sub, subscribers, color) {
|
||||
if (sub === undefined) {
|
||||
blueslip.error("Undefined sub passed to mark_subscribed");
|
||||
return;
|
||||
@@ -125,9 +123,9 @@ exports.mark_subscribed = function (sub, subscribers, color) {
|
||||
message_util.do_unread_count_updates(message_list.all.all_messages());
|
||||
|
||||
stream_list.add_sidebar_row(sub);
|
||||
};
|
||||
}
|
||||
|
||||
exports.mark_unsubscribed = function (sub) {
|
||||
export function mark_unsubscribed(sub) {
|
||||
if (sub === undefined) {
|
||||
// We don't know about this stream
|
||||
return;
|
||||
@@ -149,9 +147,9 @@ exports.mark_unsubscribed = function (sub) {
|
||||
}
|
||||
|
||||
stream_list.remove_sidebar_row(sub.stream_id);
|
||||
};
|
||||
}
|
||||
|
||||
exports.remove_deactivated_user_from_all_streams = function (user_id) {
|
||||
export function remove_deactivated_user_from_all_streams(user_id) {
|
||||
const all_subs = stream_data.get_unsorted_subs();
|
||||
|
||||
for (const sub of all_subs) {
|
||||
@@ -160,6 +158,4 @@ exports.remove_deactivated_user_from_all_streams = function (user_id) {
|
||||
subs.update_subscribers_ui(sub);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.stream_events = exports;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user