Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_list_data: Fix type of first, first_including_muted.

Anders Kaseorg931f51520761
diff --git a/web/src/message_list_data.ts b/web/src/message_list_data.ts
index 8d1324eef5a..ba6a12a9506 100644
--- a/web/src/message_list_data.ts
+++ b/web/src/message_list_data.ts
@@ -84,11 +84,11 @@ export class MessageListData {
return this._items.length === 0;
}
- first(): Message {
+ first(): Message | undefined {
return this._items[0];
}
- first_including_muted(): Message {
+ first_including_muted(): Message | undefined {
return this._all_items[0];
}
@@ -105,7 +105,7 @@ export class MessageListData {
return false;
}
- return this.first().id <= msg_id && msg_id <= this.last()!.id;
+ return this.first()!.id <= msg_id && msg_id <= this.last()!.id;
}
ids_greater_or_equal_than(my_id: number): number[] {
@@ -335,7 +335,7 @@ export class MessageListData {
const last = this.last_including_muted();
if (last === undefined || msg.id > last.id) {
bottom_messages.push(msg);
- } else if (msg.id < this.first_including_muted().id) {
+ } else if (msg.id < this.first_including_muted()!.id) {
top_messages.push(msg);
} else {
interior_messages.push(msg);
diff --git a/web/src/stream_topic_history.ts b/web/src/stream_topic_history.ts
index a148b90d304..c0a3df5e977 100644
--- a/web/src/stream_topic_history.ts
+++ b/web/src/stream_topic_history.ts
@@ -42,7 +42,7 @@ export function all_topics_in_cache(sub: StreamSubscription): boolean {
// we might be missing the oldest topics in this stream in our
// cache.
const first_cached_message = all_messages_data.first();
- return first_cached_message.id <= sub.first_message_id;
+ return first_cached_message!.id <= sub.first_message_id;
}
export function is_complete_for_stream_id(stream_id: number): boolean {