mirror of https://github.com/zulip/zulip.git
message_live_update: Convert module to TypeScript.
This commit is contained in:
parent
5fd6a819d4
commit
c91ca3eca8
|
@ -139,7 +139,7 @@ EXEMPT_FILES = make_set(
|
|||
"web/src/message_list_tooltips.js",
|
||||
"web/src/message_list_view.js",
|
||||
"web/src/message_lists.ts",
|
||||
"web/src/message_live_update.js",
|
||||
"web/src/message_live_update.ts",
|
||||
"web/src/message_notifications.js",
|
||||
"web/src/message_scroll.js",
|
||||
"web/src/message_scroll_state.ts",
|
||||
|
|
|
@ -2,13 +2,13 @@ import * as message_lists from "./message_lists";
|
|||
import * as message_store from "./message_store";
|
||||
import * as people from "./people";
|
||||
|
||||
export function rerender_messages_view() {
|
||||
export function rerender_messages_view(): void {
|
||||
for (const list of message_lists.all_rendered_message_lists()) {
|
||||
list.rerender_view();
|
||||
}
|
||||
}
|
||||
|
||||
export function rerender_messages_view_by_message_ids(message_ids) {
|
||||
export function rerender_messages_view_by_message_ids(message_ids: number[]): void {
|
||||
const messages_to_render = [];
|
||||
for (const id of message_ids) {
|
||||
const message = message_store.get(id);
|
||||
|
@ -21,7 +21,7 @@ export function rerender_messages_view_by_message_ids(message_ids) {
|
|||
}
|
||||
}
|
||||
|
||||
function rerender_messages_view_for_user(user_id) {
|
||||
function rerender_messages_view_for_user(user_id: number): void {
|
||||
for (const list of message_lists.all_rendered_message_lists()) {
|
||||
const messages = list.data.get_messages_sent_by_user(user_id);
|
||||
if (messages.length === 0) {
|
||||
|
@ -31,7 +31,10 @@ function rerender_messages_view_for_user(user_id) {
|
|||
}
|
||||
}
|
||||
|
||||
export function update_message_in_all_views(message_id, callback) {
|
||||
export function update_message_in_all_views(
|
||||
message_id: number,
|
||||
callback: ($row: JQuery) => void,
|
||||
): void {
|
||||
for (const msg_list of message_lists.all_rendered_message_lists()) {
|
||||
const $row = msg_list.get_row(message_id);
|
||||
if ($row === undefined) {
|
||||
|
@ -43,7 +46,7 @@ export function update_message_in_all_views(message_id, callback) {
|
|||
}
|
||||
}
|
||||
|
||||
export function update_starred_view(message_id, new_value) {
|
||||
export function update_starred_view(message_id: number, new_value: boolean): void {
|
||||
const starred = new_value;
|
||||
|
||||
// Avoid a full re-render, but update the star in each message
|
||||
|
@ -65,24 +68,24 @@ export function update_starred_view(message_id, new_value) {
|
|||
});
|
||||
}
|
||||
|
||||
export function update_stream_name(stream_id, new_name) {
|
||||
export function update_stream_name(stream_id: number, new_name: string): void {
|
||||
message_store.update_stream_name(stream_id, new_name);
|
||||
rerender_messages_view();
|
||||
}
|
||||
|
||||
export function update_user_full_name(user_id, full_name) {
|
||||
export function update_user_full_name(user_id: number, full_name: string): void {
|
||||
message_store.update_sender_full_name(user_id, full_name);
|
||||
rerender_messages_view_for_user(user_id);
|
||||
}
|
||||
|
||||
export function update_avatar(user_id, avatar_url) {
|
||||
export function update_avatar(user_id: number, avatar_url: string): void {
|
||||
let url = avatar_url;
|
||||
url = people.format_small_avatar_url(url);
|
||||
message_store.update_small_avatar_url(user_id, url);
|
||||
rerender_messages_view_for_user(user_id);
|
||||
}
|
||||
|
||||
export function update_user_status_emoji(user_id, status_emoji_info) {
|
||||
export function update_user_status_emoji(user_id: number, status_emoji_info: string): void {
|
||||
message_store.update_status_emoji_info(user_id, status_emoji_info);
|
||||
rerender_messages_view_for_user(user_id);
|
||||
}
|
Loading…
Reference in New Issue