message_view: Fix error thrown on deleting stream and searching for it.

Previously, when a stream is deleted and the deleted stream is looked
up in the search bar, then an error is thrown.

This is because, when the StreamSubscription object of the deleted
stream is fetched we try to access its properties - invite_only and
is_web_public, despite it being undefined.

This is fixed by accessing the properties only when the object is not
undefined.
This commit is contained in:
roanster007 2024-03-18 18:16:15 +05:30 committed by Tim Abbott
parent 446de85e76
commit 3d152296f6
1 changed files with 2 additions and 2 deletions

View File

@ -340,8 +340,8 @@ export class MessageList {
let just_unsubscribed = false;
const subscribed = stream_data.is_subscribed_by_name(stream_name);
const sub = stream_data.get_sub(stream_name);
const invite_only = sub.invite_only;
const is_web_public = sub.is_web_public;
const invite_only = sub && sub.invite_only;
const is_web_public = sub && sub.is_web_public;
const can_toggle_subscription =
sub !== undefined && stream_data.can_toggle_subscription(sub);
if (sub === undefined) {