Files
zulip/static/js/message_live_update.js
Suyash Vardhan Mathur 20a97bdb05 events: Add functionality to mark messages as unread.
Co-authored-by: Steve Howell <showell@zulip.com>
Co-authored-by: Tim Abbott <tabbott@zulip.com>

This commit adds the backend functionality to
mark messages as unread through update_message_flags
with `unread` flag and `remove` operation.

We also manage incoming events in the webapp.

Tweaked by tabbott to simplify the implementation and add an API
feature level update to the documentation.

This commit was originally drafted by showell, and showell
also finalized the changes.  Many thanks to Suyash here for
the main work here, which was to get all the tests and
documentation work moving forward.
2022-03-15 18:00:35 -07:00

51 lines
1.6 KiB
JavaScript

import * as message_list from "./message_list";
import * as message_lists from "./message_lists";
import * as message_store from "./message_store";
import * as people from "./people";
export function rerender_messages_view() {
for (const list of [message_lists.home, message_list.narrowed]) {
if (list === undefined) {
continue;
}
if (list.table_name !== undefined) {
list.rerender_view();
}
}
}
function rerender_messages_view_for_user(user_id) {
for (const list of [message_lists.home, message_list.narrowed]) {
if (list?.table_name === undefined) {
continue;
}
const messages = list.data.get_messages_sent_by_user(user_id);
if (messages.length === 0) {
continue;
}
list.view.rerender_messages(messages);
}
}
export function update_stream_name(stream_id, new_name) {
message_store.update_property("stream_name", new_name, {stream_id});
rerender_messages_view();
}
export function update_user_full_name(user_id, full_name) {
message_store.update_property("sender_full_name", full_name, {user_id});
rerender_messages_view_for_user(user_id);
}
export function update_avatar(user_id, avatar_url) {
let url = avatar_url;
url = people.format_small_avatar_url(url);
message_store.update_property("small_avatar_url", url, {user_id});
rerender_messages_view_for_user(user_id);
}
export function update_user_status_emoji(user_id, status_emoji_info) {
message_store.update_property("status_emoji_info", status_emoji_info, {user_id});
rerender_messages_view_for_user(user_id);
}