From 808c24aef2ba302d6afd41d4f0091aebff3100b3 Mon Sep 17 00:00:00 2001 From: evykassirer Date: Thu, 10 Oct 2024 11:28:36 -0700 Subject: [PATCH] typescript: Convert some && constructions to optional chains. Some upcoming changes to how types are constructed are going to bring up these type linter errors, so fix them now. --- web/src/message_list.ts | 4 ++-- web/src/user_profile.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/message_list.ts b/web/src/message_list.ts index 78604f489a..ab60d4d519 100644 --- a/web/src/message_list.ts +++ b/web/src/message_list.ts @@ -428,8 +428,8 @@ export class MessageList { let deactivated = false; let just_unsubscribed = false; const subscribed = stream_data.is_subscribed(stream_id); - const invite_only = sub && sub.invite_only; - const is_web_public = sub && sub.is_web_public; + const invite_only = sub?.invite_only; + const is_web_public = sub?.is_web_public; const can_toggle_subscription = sub !== undefined && stream_data.can_toggle_subscription(sub); if (sub === undefined) { diff --git a/web/src/user_profile.ts b/web/src/user_profile.ts index 07645a1eee..71d071a40b 100644 --- a/web/src/user_profile.ts +++ b/web/src/user_profile.ts @@ -323,7 +323,7 @@ function render_user_stream_list(streams: StreamSubscription[], user: User): voi filter: { $element: $("#user-profile-streams-tab .stream-search"), predicate(item, value) { - return item && item.name.toLocaleLowerCase().includes(value); + return item?.name.toLocaleLowerCase().includes(value); }, onupdate() { if ($container.find(".empty-table-message").length) {