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 @typescript-eslint/prefer-optional-chain.

Anders Kaseorgcd1651ce48cb
diff --git a/web/src/recent_senders.ts b/web/src/recent_senders.ts
index b40bf17dce2..c03239fa540 100644
--- a/web/src/recent_senders.ts
+++ b/web/src/recent_senders.ts
@@ -190,7 +190,7 @@ export function process_topic_edit(opts: {
export function update_topics_of_deleted_message_ids(message_ids: number[]): void {
for (const message_id of message_ids) {
const message = message_store.get(message_id);
- if (!message || message.type !== "stream") {
+ if (message?.type !== "stream") {
continue;
}
diff --git a/web/src/rendered_markdown.ts b/web/src/rendered_markdown.ts
index 90540328086..b8500ff1bce 100644
--- a/web/src/rendered_markdown.ts
+++ b/web/src/rendered_markdown.ts
@@ -141,7 +141,7 @@ export const update_elements = ($content: JQuery): void => {
user_id !== undefined && user_id !== "*" && people.is_valid_bot_user(user_id);
// We give special highlights to the mention buttons
// that refer to the current user.
- if (user_id === "*" && message && message.stream_wildcard_mentioned) {
+ if (user_id === "*" && message?.stream_wildcard_mentioned) {
$(this).addClass("user-mention-me");
}
if (user_id !== undefined && user_id !== "*" && people.is_my_user_id(user_id) && message) {
@@ -179,7 +179,7 @@ export const update_elements = ($content: JQuery): void => {
$content.find(".topic-mention").each(function (): void {
const message = get_message_for_message_content($content);
- if (message && message.topic_wildcard_mentioned) {
+ if (message?.topic_wildcard_mentioned) {
$(this).addClass("user-mention-me");
}
diff --git a/web/src/settings_data.ts b/web/src/settings_data.ts
index 8b45912ec38..4c36d84f97c 100644
--- a/web/src/settings_data.ts
+++ b/web/src/settings_data.ts
@@ -313,8 +313,7 @@ export function using_dark_theme(): boolean {
if (
user_settings.color_scheme === settings_config.color_scheme_values.automatic.code &&
- window.matchMedia &&
- window.matchMedia("(prefers-color-scheme: dark)").matches
+ window.matchMedia?.("(prefers-color-scheme: dark)").matches
) {
return true;
}