mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
eslint: Fix @typescript-eslint/prefer-optional-chain.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
8396c14cdc
commit
cd1ced82d6
@@ -683,7 +683,7 @@ export function initialize(): void {
|
||||
const $elem = $(this);
|
||||
const user_ids_string = $elem.attr("data-user-ids-string");
|
||||
// Don't show tooltip for group direct messages.
|
||||
if (!user_ids_string || user_ids_string.split(",").length !== 1) {
|
||||
if (user_ids_string?.split(",").length !== 1) {
|
||||
return;
|
||||
}
|
||||
const title_data = recent_view_ui.get_pm_tooltip_data(user_ids_string);
|
||||
|
||||
@@ -127,7 +127,7 @@ export function is_white_space_pre(paste_html: string): boolean {
|
||||
|
||||
function is_from_excel(html_fragment: HTMLBodyElement): boolean {
|
||||
const html_tag = html_fragment.parentElement;
|
||||
if (!html_tag || html_tag.nodeName !== "HTML") {
|
||||
if (html_tag?.nodeName !== "HTML") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ function is_from_excel(html_fragment: HTMLBodyElement): boolean {
|
||||
// something like LibreOffice Writer.
|
||||
function is_from_libreoffice_calc(body_tag: HTMLBodyElement): boolean {
|
||||
const html_tag = body_tag.parentElement;
|
||||
if (!html_tag || html_tag.nodeName !== "HTML") {
|
||||
if (html_tag?.nodeName !== "HTML") {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1253,8 +1253,7 @@ export function content_typeahead_selected(
|
||||
const sub = stream_data.get_sub_by_name(item.name);
|
||||
const is_empty_topic_only_channel =
|
||||
sub && stream_data.is_empty_topic_only_channel(sub.stream_id);
|
||||
const is_greater_than_key_pressed =
|
||||
event && event.type === "keydown" && event.key === ">";
|
||||
const is_greater_than_key_pressed = event?.type === "keydown" && event.key === ">";
|
||||
|
||||
// For empty topic only channel, skip showing topic typeahead and
|
||||
// insert direct channel link.
|
||||
|
||||
@@ -1199,7 +1199,7 @@ function process_hotkey(e: JQuery.KeyDownEvent, hotkey: Hotkey): boolean {
|
||||
case "toggle_topic_visibility_policy":
|
||||
if (recent_view_ui.is_in_focus()) {
|
||||
const recent_msg = recent_view_ui.get_focused_row_message();
|
||||
if (recent_msg !== undefined && recent_msg.type === "stream") {
|
||||
if (recent_msg?.type === "stream") {
|
||||
user_topics_ui.toggle_topic_visibility_policy(recent_msg);
|
||||
return true;
|
||||
}
|
||||
@@ -1217,13 +1217,13 @@ function process_hotkey(e: JQuery.KeyDownEvent, hotkey: Hotkey): boolean {
|
||||
case "list_of_channel_topics":
|
||||
if (recent_view_ui.is_in_focus()) {
|
||||
const msg = recent_view_ui.get_focused_row_message();
|
||||
if (msg !== undefined && msg.type === "stream") {
|
||||
if (msg?.type === "stream") {
|
||||
list_of_channel_topics_channel_id = msg.stream_id;
|
||||
}
|
||||
}
|
||||
if (inbox_ui.is_in_focus()) {
|
||||
const msg = inbox_ui.get_focused_row_message();
|
||||
if (msg !== undefined && msg.msg_type === "stream") {
|
||||
if (msg?.msg_type === "stream") {
|
||||
list_of_channel_topics_channel_id = msg.stream_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,7 @@ export function show_generate_integration_url_modal(api_key: string): void {
|
||||
|
||||
if (
|
||||
!$("#integration-url-all-branches").prop("checked") &&
|
||||
branch_pill_widget !== undefined &&
|
||||
branch_pill_widget.items().length === 0
|
||||
branch_pill_widget?.items().length === 0
|
||||
) {
|
||||
branch_pill_widget.appendValue("main");
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ export function reset_ui_state(opts: {trigger?: string}): void {
|
||||
// Most users aren't going to send a bunch of a out-of-narrow messages
|
||||
// and expect to visit a list of narrows, so let's get these out of the way.
|
||||
let skip_automatic_new_visibility_policy_banner = false;
|
||||
if (opts && opts.trigger === "outside_current_view") {
|
||||
if (opts?.trigger === "outside_current_view") {
|
||||
skip_automatic_new_visibility_policy_banner = true;
|
||||
}
|
||||
compose_banner.clear_message_sent_banners(true, skip_automatic_new_visibility_policy_banner);
|
||||
|
||||
@@ -322,7 +322,7 @@ export const update_elements = ($content: JQuery): void => {
|
||||
const $codehilite = $(this);
|
||||
const $pre = $codehilite.find("pre");
|
||||
const fenced_code_lang = $codehilite.attr("data-code-language");
|
||||
let playground_info;
|
||||
let playground_info: realm_playground.RealmPlayground[] | undefined;
|
||||
if (fenced_code_lang !== undefined) {
|
||||
playground_info = realm_playground.get_playground_info_for_languages(fenced_code_lang);
|
||||
}
|
||||
@@ -339,11 +339,7 @@ export const update_elements = ($content: JQuery): void => {
|
||||
// popover listing the options.
|
||||
let title = $t({defaultMessage: "View in playground"});
|
||||
const $view_in_playground_button = $buttonContainer.find(".code_external_link");
|
||||
if (
|
||||
playground_info &&
|
||||
playground_info.length === 1 &&
|
||||
playground_info[0] !== undefined
|
||||
) {
|
||||
if (playground_info?.length === 1 && playground_info[0] !== undefined) {
|
||||
title = $t(
|
||||
{defaultMessage: "View in {playground_name}"},
|
||||
{playground_name: playground_info[0].name},
|
||||
|
||||
@@ -66,7 +66,7 @@ export function initialize(): void {
|
||||
|
||||
// Allow selecting text inside a spoiler header.
|
||||
const selection = document.getSelection();
|
||||
if (selection && selection.type === "Range") {
|
||||
if (selection?.type === "Range") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -597,7 +597,7 @@ class UnreadTopicCounter {
|
||||
// topic in this stream containing a given unread message
|
||||
// ID. If it's not in this stream, we'll get undefined.
|
||||
const stream_topic = this.reverse_lookup.get(message_id);
|
||||
if (stream_topic !== undefined && stream_topic.stream_id === stream_id) {
|
||||
if (stream_topic?.stream_id === stream_id) {
|
||||
// Important: We lower-case topics here before adding them
|
||||
// to this set, to support case-insensitive checks.
|
||||
result.add(stream_topic.topic.toLowerCase());
|
||||
|
||||
Reference in New Issue
Block a user