mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
js: Convert static/js/user_status.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
229aacb819
commit
583febeffd
@@ -291,7 +291,6 @@
|
||||
"user_events": false,
|
||||
"user_groups": false,
|
||||
"user_pill": false,
|
||||
"user_status": false,
|
||||
"user_status_ui": false,
|
||||
"poll_widget": false,
|
||||
"vdom": false,
|
||||
|
||||
@@ -22,7 +22,6 @@ const vdom = set_global("vdom", {
|
||||
});
|
||||
const pm_list_dom = set_global("pm_list_dom", {});
|
||||
|
||||
zrequire("user_status");
|
||||
zrequire("presence");
|
||||
zrequire("buddy_data");
|
||||
zrequire("hash_util");
|
||||
|
||||
@@ -119,7 +119,6 @@ zrequire("sent_messages");
|
||||
zrequire("typing");
|
||||
zrequire("top_left_corner");
|
||||
zrequire("starred_messages");
|
||||
zrequire("user_status");
|
||||
zrequire("user_status_ui");
|
||||
|
||||
const ui_init = rewiremock.proxy(() => zrequire("ui_init"), {
|
||||
|
||||
@@ -4,6 +4,7 @@ const _ = require("lodash");
|
||||
|
||||
const people = require("./people");
|
||||
const {UserSearch} = require("./user_search");
|
||||
const user_status = require("./user_status");
|
||||
|
||||
/*
|
||||
Helpers for detecting user activity and managing user idle states
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const people = require("./people");
|
||||
const user_status = require("./user_status");
|
||||
const util = require("./util");
|
||||
/*
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ import "../message_fetch";
|
||||
import "../server_events";
|
||||
import "../zulip";
|
||||
import "../presence";
|
||||
import "../user_status";
|
||||
import "../user_status_ui";
|
||||
import "../buddy_data";
|
||||
import "../padded_widget";
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const autosize = require("autosize");
|
||||
|
||||
const people = require("./people");
|
||||
const user_status = require("./user_status");
|
||||
|
||||
exports.autosize_textarea = function (textarea) {
|
||||
// Since this supports both compose and file upload, one must pass
|
||||
|
||||
1
static/js/global.d.ts
vendored
1
static/js/global.d.ts
vendored
@@ -156,6 +156,5 @@ declare let upload_widget: any;
|
||||
declare let user_events: any;
|
||||
declare let user_groups: any;
|
||||
declare let user_pill: any;
|
||||
declare let user_status: any;
|
||||
declare let user_status_ui: any;
|
||||
declare let widgetize: any;
|
||||
|
||||
@@ -21,6 +21,7 @@ const message_edit_history = require("./message_edit_history");
|
||||
const people = require("./people");
|
||||
const settings_config = require("./settings_config");
|
||||
const settings_data = require("./settings_data");
|
||||
const user_status = require("./user_status");
|
||||
const util = require("./util");
|
||||
|
||||
let current_actions_popover_elem;
|
||||
|
||||
@@ -4,6 +4,7 @@ import * as alert_words from "./alert_words";
|
||||
import * as peer_data from "./peer_data";
|
||||
import * as people from "./people";
|
||||
import * as settings_config from "./settings_config";
|
||||
import * as user_status from "./user_status";
|
||||
|
||||
export function dispatch_normal_event(event) {
|
||||
const noop = function () {};
|
||||
|
||||
@@ -17,6 +17,7 @@ const markdown_config = require("./markdown_config");
|
||||
const people = require("./people");
|
||||
const pm_conversations = require("./pm_conversations");
|
||||
const topic_zoom = require("./topic_zoom");
|
||||
const user_status = require("./user_status");
|
||||
|
||||
// This is where most of our initialization takes place.
|
||||
// TODO: Organize it a lot better. In particular, move bigger
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const away_user_ids = new Set();
|
||||
const user_info = new Map();
|
||||
|
||||
exports.server_update = function (opts) {
|
||||
export function server_update(opts) {
|
||||
channel.post({
|
||||
url: "/json/users/me/status",
|
||||
data: {
|
||||
@@ -17,48 +15,48 @@ exports.server_update = function (opts) {
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
exports.server_set_away = function () {
|
||||
exports.server_update({away: true});
|
||||
};
|
||||
export function server_set_away() {
|
||||
server_update({away: true});
|
||||
}
|
||||
|
||||
exports.server_revoke_away = function () {
|
||||
exports.server_update({away: false});
|
||||
};
|
||||
export function server_revoke_away() {
|
||||
server_update({away: false});
|
||||
}
|
||||
|
||||
exports.set_away = function (user_id) {
|
||||
export function set_away(user_id) {
|
||||
if (typeof user_id !== "number") {
|
||||
blueslip.error("need ints for user_id");
|
||||
}
|
||||
away_user_ids.add(user_id);
|
||||
};
|
||||
}
|
||||
|
||||
exports.revoke_away = function (user_id) {
|
||||
export function revoke_away(user_id) {
|
||||
if (typeof user_id !== "number") {
|
||||
blueslip.error("need ints for user_id");
|
||||
}
|
||||
away_user_ids.delete(user_id);
|
||||
};
|
||||
}
|
||||
|
||||
exports.is_away = function (user_id) {
|
||||
export function is_away(user_id) {
|
||||
return away_user_ids.has(user_id);
|
||||
};
|
||||
}
|
||||
|
||||
exports.get_status_text = function (user_id) {
|
||||
export function get_status_text(user_id) {
|
||||
return user_info.get(user_id);
|
||||
};
|
||||
}
|
||||
|
||||
exports.set_status_text = function (opts) {
|
||||
export function set_status_text(opts) {
|
||||
if (!opts.status_text) {
|
||||
user_info.delete(opts.user_id);
|
||||
return;
|
||||
}
|
||||
|
||||
user_info.set(opts.user_id, opts.status_text);
|
||||
};
|
||||
}
|
||||
|
||||
exports.initialize = function (params) {
|
||||
export function initialize(params) {
|
||||
for (const [str_user_id, dct] of Object.entries(params.user_status)) {
|
||||
// JSON does not allow integer keys, so we
|
||||
// convert them here.
|
||||
@@ -72,6 +70,4 @@ exports.initialize = function (params) {
|
||||
user_info.set(user_id, dct.status_text);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.user_status = exports;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const people = require("./people");
|
||||
const user_status = require("./user_status");
|
||||
|
||||
exports.input_field = function () {
|
||||
return $(".user_status_overlay input.user_status");
|
||||
|
||||
Reference in New Issue
Block a user