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.

eslint: Fix unicorn/prefer-logical-operator-over-ternary.

Anders Kaseorg27a486781a3f
diff --git a/web/src/click_handlers.ts b/web/src/click_handlers.ts
index 643db5caef8..169d063ce6f 100644
--- a/web/src/click_handlers.ts
+++ b/web/src/click_handlers.ts
@@ -692,7 +692,8 @@ export function initialize(): void {
user_settings.user_list_style ===
settings_config.user_list_style_values.compact.code;
const status_el = is_compact_mode ? null : util.the($elem.find(".status-text"));
- const is_truncated = status_el ? status_el.scrollWidth > status_el.clientWidth : false;
+ const is_truncated =
+ status_el !== null && status_el.scrollWidth > status_el.clientWidth;
const should_show_status = is_compact_mode || is_truncated;
const user_id_string = $elem.attr("data-user-id")!;
diff --git a/web/src/drafts.ts b/web/src/drafts.ts
index 26c1c461825..23a07ba7a95 100644
--- a/web/src/drafts.ts
+++ b/web/src/drafts.ts
@@ -475,7 +475,8 @@ export let update_draft = (opts: UpdateDraftOptions = {}): string | undefined =>
if (opts.is_sending_saving !== undefined) {
draft.is_sending_saving = opts.is_sending_saving;
} else {
- draft.is_sending_saving = old_draft ? old_draft.is_sending_saving : false;
+ draft.is_sending_saving =
+ old_draft !== undefined && old_draft !== false && old_draft.is_sending_saving;
}
// Now that it's been updated, we consider it to be the most recent version.
diff --git a/web/src/stream_data.ts b/web/src/stream_data.ts
index d93c5e0bbbc..e778e9c49ec 100644
--- a/web/src/stream_data.ts
+++ b/web/src/stream_data.ts
@@ -1038,7 +1038,7 @@ export function user_can_move_messages_within_channel(stream: StreamSubscription
export function is_subscribed(stream_id: number): boolean {
const sub = sub_store.get(stream_id);
- return sub ? sub.subscribed : false;
+ return sub?.subscribed ?? false;
}
export function get_stream_privacy_policy(stream_id: number): string {
@@ -1057,12 +1057,12 @@ export function is_stream_archived_by_id(stream_id: number): boolean {
// If you've already got a channel object, you can just use
// `sub.is_archived` directly instead of calling this function.
const sub = sub_store.get(stream_id);
- return sub ? sub.is_archived : false;
+ return sub?.is_archived ?? false;
}
export function is_web_public(stream_id: number): boolean {
const sub = sub_store.get(stream_id);
- return sub ? sub.is_web_public : false;
+ return sub?.is_web_public ?? false;
}
export function is_invite_only_by_stream_id(stream_id: number): boolean {
diff --git a/web/src/ui_util.ts b/web/src/ui_util.ts
index 0de45c06dc7..50915ddf09e 100644
--- a/web/src/ui_util.ts
+++ b/web/src/ui_util.ts
@@ -100,7 +100,7 @@ export function is_user_said_paragraph($element: JQuery): boolean {
}
const $message_link = $element.find("a[href]").filter((_index, element) => {
const href = $(element).attr("href")!;
- return href ? hash_parser.is_same_server_message_link(href) : false;
+ return href !== "" && hash_parser.is_same_server_message_link(href);
});
if ($message_link.length !== 1) {
return false;