mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
Despite the length of this commit, it is a very straightforward
moving of code from narrow.js -> narrow_state.js, and then
everything else is just s/narrow.foo()/narrow_state.foo()/
(with a few tiny cleanups to remove some code duplication
in certain callers).
The only new functions are simple setter/getters that
encapsulate the current_filter variable:
narrow_state.reset_current_filter()
narrow_state.set_current_filter()
narrow_state.get_current_filter()
We removed narrow.predicate() as part of this, since it was dead
code.
Also, we removed the shim for narrow_state.set_compose_defaults(),
and since that was the last shim, we removed shim.js from the app.
74 lines
2.0 KiB
JavaScript
74 lines
2.0 KiB
JavaScript
var user_events = (function () {
|
|
|
|
var exports = {};
|
|
|
|
// This module is kind of small, but it will help us keep
|
|
// server_events.js simple while breaking some circular
|
|
// dependencies that existed when this code was in people.js.
|
|
// (We should do bot updates here too.)
|
|
|
|
exports.update_person = function update(person) {
|
|
var person_obj = people.get_person_from_user_id(person.user_id);
|
|
|
|
if (!person_obj) {
|
|
blueslip.error("Got update_person event for unexpected user",
|
|
{email: person.user_id});
|
|
return;
|
|
}
|
|
|
|
if (_.has(person, 'new_email')) {
|
|
var user_id = person.user_id;
|
|
var new_email = person.new_email;
|
|
|
|
narrow_state.update_email(user_id, new_email);
|
|
compose.update_email(user_id, new_email);
|
|
|
|
if (people.is_my_user_id(person.user_id)) {
|
|
settings_account.update_email(new_email);
|
|
}
|
|
|
|
people.update_email(user_id, new_email);
|
|
}
|
|
|
|
if (_.has(person, 'full_name')) {
|
|
people.set_full_name(person_obj, person.full_name);
|
|
|
|
settings_users.update_user_data(person.user_id, person);
|
|
activity.redraw();
|
|
message_live_update.update_user_full_name(person.user_id, person.full_name);
|
|
pm_list.update_private_messages();
|
|
}
|
|
|
|
if (_.has(person, 'is_admin')) {
|
|
person_obj.is_admin = person.is_admin;
|
|
|
|
if (people.is_my_user_id(person.user_id)) {
|
|
page_params.is_admin = person.is_admin;
|
|
admin.show_or_hide_menu_item();
|
|
}
|
|
}
|
|
|
|
if (_.has(person, 'avatar_url')) {
|
|
var url = person.avatar_url;
|
|
person_obj.avatar_url = url;
|
|
|
|
if (people.is_my_user_id(person.user_id)) {
|
|
page_params.avatar_url = url;
|
|
$("#user-settings-avatar").attr("src", url);
|
|
}
|
|
|
|
message_live_update.update_avatar(person_obj.user_id, person.avatar_url);
|
|
}
|
|
|
|
if (_.has(person, 'timezone')) {
|
|
person_obj.timezone = person.timezone;
|
|
}
|
|
};
|
|
|
|
return exports;
|
|
|
|
}());
|
|
if (typeof module !== 'undefined') {
|
|
module.exports = user_events;
|
|
}
|