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 Kaseorgc943dc503599
diff --git a/web/src/activity.ts b/web/src/activity.ts
index 5072f7df955..e29cee9b8f5 100644
--- a/web/src/activity.ts
+++ b/web/src/activity.ts
@@ -76,10 +76,7 @@ export function compute_active_status(): ActivityState {
//
// The check for `get_idle_on_system === undefined` is feature
// detection; older desktop app releases never set that property.
- if (
- window.electron_bridge !== undefined &&
- window.electron_bridge.get_idle_on_system !== undefined
- ) {
+ if (window.electron_bridge?.get_idle_on_system !== undefined) {
if (window.electron_bridge.get_idle_on_system()) {
return ActivityState.IDLE;
}
diff --git a/web/src/portico/desktop-login.ts b/web/src/portico/desktop-login.ts
index d20c84defaf..386b2c00954 100644
--- a/web/src/portico/desktop-login.ts
+++ b/web/src/portico/desktop-login.ts
@@ -42,10 +42,9 @@ void (async () => {
// key and a promise; as soon as something encrypted to that key is copied
// to the clipboard, the app decrypts it and resolves the promise to the
// plaintext. This lets us skip the manual paste step.
- const {key, pasted} =
- window.electron_bridge && window.electron_bridge.decrypt_clipboard
- ? window.electron_bridge.decrypt_clipboard(1)
- : await decrypt_manual();
+ const {key, pasted} = window.electron_bridge?.decrypt_clipboard
+ ? window.electron_bridge.decrypt_clipboard(1)
+ : await decrypt_manual();
const keyHex = [...key].map((b) => b.toString(16).padStart(2, "0")).join("");
window.open(
diff --git a/web/src/presence.ts b/web/src/presence.ts
index 651f2217821..8e6156e58ac 100644
--- a/web/src/presence.ts
+++ b/web/src/presence.ts
@@ -271,7 +271,7 @@ export function update_info_for_small_realm(): void {
export function last_active_date(user_id: number): Date | undefined {
const info = presence_info.get(user_id);
- if (!info || !info.last_active) {
+ if (!info?.last_active) {
return undefined;
}
diff --git a/web/src/user_topics.ts b/web/src/user_topics.ts
index e0f0facf021..10298b9a0b7 100644
--- a/web/src/user_topics.ts
+++ b/web/src/user_topics.ts
@@ -73,11 +73,7 @@ export function get_topic_visibility_policy(stream_id: number, topic: string): n
return false;
}
const sub_dict = all_user_topics.get(stream_id);
- if (sub_dict && sub_dict.get(topic)) {
- return sub_dict.get(topic)!.visibility_policy;
- }
-
- return all_visibility_policies.INHERIT;
+ return sub_dict?.get(topic)?.visibility_policy ?? all_visibility_policies.INHERIT;
}
export function is_topic_followed(stream_id: number, topic: string): boolean {