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_view: Remove incorrect assert for p keyboard shortcut.

Tim Abbott0fa4cd9d098e
diff --git a/web/src/message_view.ts b/web/src/message_view.ts
index e219ddecfec..025aae42214 100644
--- a/web/src/message_view.ts
+++ b/web/src/message_view.ts
@@ -1233,8 +1233,6 @@ export function narrow_to_next_topic(opts: {trigger: string; only_followed_topic
export function narrow_to_next_pm_string(opts = {}): void {
const current_direct_message = narrow_state.pm_ids_string();
- assert(current_direct_message !== undefined);
-
const next_direct_message = topic_generator.get_next_unread_pm_string(current_direct_message);
if (!next_direct_message) {
diff --git a/web/src/topic_generator.ts b/web/src/topic_generator.ts
index 049f15ce3f2..0ab63adb9fb 100644
--- a/web/src/topic_generator.ts
+++ b/web/src/topic_generator.ts
@@ -136,9 +136,13 @@ export function get_next_topic(
);
}
-export function get_next_unread_pm_string(curr_pm: string): string | undefined {
+export function get_next_unread_pm_string(curr_pm: string | undefined): string | undefined {
const my_pm_strings = pm_conversations.recent.get_strings();
- const curr_pm_index = my_pm_strings.indexOf(curr_pm); // -1 if not found
+ // undefined translates to "not found".
+ let curr_pm_index = -1;
+ if (curr_pm !== undefined) {
+ curr_pm_index = my_pm_strings.indexOf(curr_pm);
+ }
for (let i = curr_pm_index + 1; i < my_pm_strings.length; i += 1) {
if (unread.num_unread_for_user_ids_string(my_pm_strings[i]!) > 0) {