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-combined-guards.

Anders Kaseorg7ac101c1bd83
diff --git a/web/e2e-tests/lib/common.ts b/web/e2e-tests/lib/common.ts
index 12ab8c7740b..070ef01f7ae 100644
--- a/web/e2e-tests/lib/common.ts
+++ b/web/e2e-tests/lib/common.ts
@@ -359,15 +359,11 @@ export async function wait_for_fully_processed_message(page: Page, content: stri
re-rendered based on server info?
*/
const last_msg = zulip_test.current_msg_list?.last();
- if (last_msg === undefined) {
- return false;
- }
-
- if (last_msg.raw_content !== content) {
- return false;
- }
-
- if (last_msg.locally_echoed) {
+ if (
+ last_msg === undefined ||
+ last_msg.raw_content !== content ||
+ last_msg.locally_echoed
+ ) {
return false;
}
diff --git a/web/src/attachments_ui.ts b/web/src/attachments_ui.ts
index 904962a7f63..891d4b81952 100644
--- a/web/src/attachments_ui.ts
+++ b/web/src/attachments_ui.ts
@@ -68,10 +68,7 @@ export function percentage_used_space(uploads_size: number): string | null {
}
function set_upload_space_stats(): void {
- if (realm.realm_upload_quota_mib === null) {
- return;
- }
- if (current_user.is_guest) {
+ if (realm.realm_upload_quota_mib === null || current_user.is_guest) {
return;
}
diff --git a/web/src/billing/event_status.ts b/web/src/billing/event_status.ts
index 417f7a31964..146f3f0a045 100644
--- a/web/src/billing/event_status.ts
+++ b/web/src/billing/event_status.ts
@@ -61,10 +61,10 @@ async function stripe_checkout_session_status_check(stripe_session_id: string):
});
const response_data = stripe_response_schema.parse(response);
- if (response_data.session.status === "created") {
- return false;
- }
- if (response_data.session.event_handler!.status === "started") {
+ if (
+ response_data.session.status === "created" ||
+ response_data.session.event_handler!.status === "started"
+ ) {
return false;
}
if (response_data.session.event_handler!.status === "succeeded") {
diff --git a/web/src/click_handlers.ts b/web/src/click_handlers.ts
index d0acf340405..ea0cbcded2e 100644
--- a/web/src/click_handlers.ts
+++ b/web/src/click_handlers.ts
@@ -598,10 +598,12 @@ export function initialize(): void {
});
$(".buddy-list-section").on("click", ".selectable_sidebar_block", (e) => {
- if (e.metaKey || e.ctrlKey || e.shiftKey) {
- return;
- }
- if ($(e.target).parents(".user-profile-picture").length === 1) {
+ if (
+ e.metaKey ||
+ e.ctrlKey ||
+ e.shiftKey ||
+ $(e.target).parents(".user-profile-picture").length === 1
+ ) {
return;
}
if (mouse_drag.is_drag(e)) {
diff --git a/web/src/components.ts b/web/src/components.ts
index 9dcbe2c73b9..1a79ce3688b 100644
--- a/web/src/components.ts
+++ b/web/src/components.ts
@@ -79,10 +79,7 @@ export function toggle(opts: {
// Returns false if the requested tab is disabled.
function select_tab(idx: number): boolean {
const $elem = meta.$ind_tab.eq(idx);
- if ($elem.hasClass("disabled")) {
- return false;
- }
- if ($elem.css("display") === "none") {
+ if ($elem.hasClass("disabled") || $elem.css("display") === "none") {
return false;
}
diff --git a/web/src/compose_actions.ts b/web/src/compose_actions.ts
index 62f78d52691..7e4a103f2c7 100644
--- a/web/src/compose_actions.ts
+++ b/web/src/compose_actions.ts
@@ -246,11 +246,7 @@ export function rewire_complete_starting_tasks(value: typeof complete_starting_t
}
export function maybe_scroll_up_selected_message(opts: ComposeActionsStartOpts): void {
- if (opts.skip_scrolling_selected_message) {
- return;
- }
-
- if (message_lists.current === undefined) {
+ if (opts.skip_scrolling_selected_message || message_lists.current === undefined) {
return;
}
diff --git a/web/src/compose_paste.ts b/web/src/compose_paste.ts
index f6f0f26d8c3..109a4a0f28d 100644
--- a/web/src/compose_paste.ts
+++ b/web/src/compose_paste.ts
@@ -164,21 +164,16 @@ function is_from_excel(html_fragment: HTMLBodyElement): boolean {
(meta.name === "ProgId" && meta.content === "Excel.Sheet") ||
(meta.name === "Generator" && meta.content?.includes("Microsoft Excel")),
);
- if (!has_excel_metadata) {
- return false;
- }
-
- if (!html_tag.querySelector("[class^='xl']")) {
+ if (!has_excel_metadata || !html_tag.querySelector("[class^='xl']")) {
return false;
}
const html_outer = html_tag.outerHTML;
- if (!html_outer.includes("<!--StartFragment-->")) {
- return false;
- }
-
- if (excel_namespaces.every((ns) => !html_outer.includes(ns))) {
+ if (
+ !html_outer.includes("<!--StartFragment-->") ||
+ excel_namespaces.every((ns) => !html_outer.includes(ns))
+ ) {
return false;
}
diff --git a/web/src/compose_tooltips.ts b/web/src/compose_tooltips.ts
index 98acc62b794..e33011645be 100644
--- a/web/src/compose_tooltips.ts
+++ b/web/src/compose_tooltips.ts
@@ -99,15 +99,11 @@ let intro_go_to_conversation_tooltip_instance: tippy.Instance | null = null;
export function maybe_show_intro_go_to_conversation_tooltip(): void {
const $button = $(".conversation-arrow");
- if (!$button.hasClass("narrow_to_compose_recipients")) {
- return;
- }
-
- if ($("#compose_banners .main-view-banner").length > 0) {
- return;
- }
-
- if (intro_go_to_conversation_tooltip_instance !== null) {
+ if (
+ !$button.hasClass("narrow_to_compose_recipients") ||
+ $("#compose_banners .main-view-banner").length > 0 ||
+ intro_go_to_conversation_tooltip_instance !== null
+ ) {
return;
}
diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.ts
index 87f0d615584..f031affe895 100644
--- a/web/src/composebox_typeahead.ts
+++ b/web/src/composebox_typeahead.ts
@@ -1626,10 +1626,7 @@ export function should_suppress_topic_typeahead(
query: string,
items: (string | UserPillData)[],
): boolean {
- if (!query) {
- return false;
- }
- if (items.some((item) => typeof item !== "string")) {
+ if (!query || items.some((item) => typeof item !== "string")) {
return false;
}
const topics = items.filter((item): item is string => typeof item === "string");
diff --git a/web/src/drafts_overlay_ui.ts b/web/src/drafts_overlay_ui.ts
index 679302b9a60..63293c273f7 100644
--- a/web/src/drafts_overlay_ui.ts
+++ b/web/src/drafts_overlay_ui.ts
@@ -348,11 +348,8 @@ function render_widgets(
function setup_event_handlers(): void {
$("#drafts_table .restore-overlay-message").on("click", function (e) {
- if (mouse_drag.is_drag(e)) {
- return;
- }
-
if (
+ mouse_drag.is_drag(e) ||
messages_overlay_ui.handle_overlay_media_click(
e,
"drafts",
diff --git a/web/src/emoji_frequency.ts b/web/src/emoji_frequency.ts
index 75c6ce25dd8..e4128b55dcf 100644
--- a/web/src/emoji_frequency.ts
+++ b/web/src/emoji_frequency.ts
@@ -20,10 +20,10 @@ function should_ignore_reaction(
reaction_sender_id?: number,
): boolean {
if (message.type === "stream") {
- if (user_topics.is_topic_muted(message.stream_id, message.topic)) {
- return true;
- }
- if (stream_data.is_muted(message.stream_id)) {
+ if (
+ user_topics.is_topic_muted(message.stream_id, message.topic) ||
+ stream_data.is_muted(message.stream_id)
+ ) {
return true;
}
}
@@ -48,10 +48,7 @@ export function update_frequently_used_emojis_list(): void {
export function update_emoji_frequency_on_add_reaction_event(event: reactions.ReactionEvent): void {
const message_id = event.message_id;
const message = message_store.get(message_id);
- if (message === undefined) {
- return;
- }
- if (should_ignore_reaction(message, event.user_id)) {
+ if (message === undefined || should_ignore_reaction(message, event.user_id)) {
return;
}
const emoji_id = reactions.get_local_reaction_id(event);
@@ -78,10 +75,7 @@ export function update_emoji_frequency_on_remove_reaction_event(
): void {
const message_id = event.message_id;
const message = message_store.get(message_id);
- if (message === undefined) {
- return;
- }
- if (should_ignore_reaction(message, event.user_id)) {
+ if (message === undefined || should_ignore_reaction(message, event.user_id)) {
return;
}
diff --git a/web/src/emoji_frequency_data.ts b/web/src/emoji_frequency_data.ts
index 4b448f25614..4db78b6ba4e 100644
--- a/web/src/emoji_frequency_data.ts
+++ b/web/src/emoji_frequency_data.ts
@@ -197,11 +197,7 @@ export function handle_reaction_removal_on_message(info: {
const {emoji_id, message_id, is_me} = info;
const reaction_usage = reaction_data.get(emoji_id);
- if (reaction_usage === undefined) {
- return;
- }
-
- if (!reaction_usage.message_ids.has(message_id)) {
+ if (!reaction_usage?.message_ids.has(message_id)) {
return;
}
reaction_usage.message_ids.delete(message_id);
diff --git a/web/src/filter.ts b/web/src/filter.ts
index a3bc5140dfa..701b5338e6e 100644
--- a/web/src/filter.ts
+++ b/web/src/filter.ts
@@ -1021,10 +1021,10 @@ export class Filter {
static is_spectator_compatible(terms: NarrowTerm[]): boolean {
for (const term of terms) {
- if (term.operand === undefined) {
- return false;
- }
- if (!hash_parser.is_an_allowed_web_public_narrow(term.operator, term.operand)) {
+ if (
+ term.operand === undefined ||
+ !hash_parser.is_an_allowed_web_public_narrow(term.operator, term.operand)
+ ) {
return false;
}
}
@@ -1338,47 +1338,19 @@ export class Filter {
return true;
}
- if (_.isEqual(term_types, ["channel", "topic"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["dm", "with"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["dm"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["channel"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["is-dm"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["not-is-dm"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["is-resolved"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["in-home"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["not-is-muted"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["in-all"])) {
- return true;
- }
-
- if (_.isEqual(term_types, ["not-channels-archived"])) {
+ if (
+ _.isEqual(term_types, ["channel", "topic"]) ||
+ _.isEqual(term_types, ["dm", "with"]) ||
+ _.isEqual(term_types, ["dm"]) ||
+ _.isEqual(term_types, ["channel"]) ||
+ _.isEqual(term_types, ["is-dm"]) ||
+ _.isEqual(term_types, ["not-is-dm"]) ||
+ _.isEqual(term_types, ["is-resolved"]) ||
+ _.isEqual(term_types, ["in-home"]) ||
+ _.isEqual(term_types, ["not-is-muted"]) ||
+ _.isEqual(term_types, ["in-all"]) ||
+ _.isEqual(term_types, ["not-channels-archived"])
+ ) {
return true;
}
@@ -1401,25 +1373,15 @@ export class Filter {
return true;
}
const term_types = this.sorted_term_types();
- if (_.isEqual(term_types, ["is-mentioned"])) {
- return true;
- }
- if (_.isEqual(term_types, ["is-starred"])) {
- return true;
- }
- if (_.isEqual(term_types, ["channels-public"])) {
- return true;
- }
- if (_.isEqual(term_types, ["channels-web-public"])) {
- return true;
- }
- if (_.isEqual(term_types, ["channels-archived"])) {
- return true;
- }
- if (_.isEqual(term_types, ["sender"])) {
- return true;
- }
- if (_.isEqual(term_types, ["is-followed"])) {
+ if (
+ _.isEqual(term_types, ["is-mentioned"]) ||
+ _.isEqual(term_types, ["is-starred"]) ||
+ _.isEqual(term_types, ["channels-public"]) ||
+ _.isEqual(term_types, ["channels-web-public"]) ||
+ _.isEqual(term_types, ["channels-archived"]) ||
+ _.isEqual(term_types, ["sender"]) ||
+ _.isEqual(term_types, ["is-followed"])
+ ) {
return true;
}
if (
diff --git a/web/src/hash_parser.ts b/web/src/hash_parser.ts
index eb886bbdcd8..9e97126ad4d 100644
--- a/web/src/hash_parser.ts
+++ b/web/src/hash_parser.ts
@@ -84,11 +84,7 @@ export function is_overlay_hash(hash: string | undefined): boolean {
export function is_editing_stream(desired_stream_id: number): boolean {
const hash_components = window.location.hash.slice(1).split(/\//);
- if (hash_components[0] !== "channels") {
- return false;
- }
-
- if (!hash_components[2]) {
+ if (hash_components[0] !== "channels" || !hash_components[2]) {
return false;
}
@@ -108,10 +104,7 @@ export function is_create_new_stream_narrow(): boolean {
export function is_subscribers_section_opened_for_stream(): boolean {
const hash_components = window.location.hash.slice(1).split(/\//);
- if (hash_components[0] !== "channels") {
- return false;
- }
- if (!hash_components[3]) {
+ if (hash_components[0] !== "channels" || !hash_components[3]) {
return false;
}
return hash_components[3] === "subscribers";
diff --git a/web/src/hash_util.ts b/web/src/hash_util.ts
index 285e6c10bde..39732ac1417 100644
--- a/web/src/hash_util.ts
+++ b/web/src/hash_util.ts
@@ -496,10 +496,7 @@ export function decode_dm_recipient_user_ids_from_narrow_url(narrow_url: string)
return null;
}
const terms = parse_narrow(url.hash.split(/\//));
- if (!terms?.[0]) {
- return null;
- }
- if (terms.length > 2) {
+ if (!terms?.[0] || terms.length > 2) {
return null;
}
// Help Typescript understand that first_term.operator can only be
diff --git a/web/src/information_density.ts b/web/src/information_density.ts
index 51c17847fa4..56eb615353a 100644
--- a/web/src/information_density.ts
+++ b/web/src/information_density.ts
@@ -226,11 +226,10 @@ export function check_setting_has_recommended_value(
property: "web_font_size_px" | "web_line_height_percent",
current_value: number,
): boolean {
- if (current_value > INFO_DENSITY_VALUES_DICT[property].maximum) {
- return false;
- }
-
- if (current_value < INFO_DENSITY_VALUES_DICT[property].minimum) {
+ if (
+ current_value > INFO_DENSITY_VALUES_DICT[property].maximum ||
+ current_value < INFO_DENSITY_VALUES_DICT[property].minimum
+ ) {
return false;
}
diff --git a/web/src/message_edit.ts b/web/src/message_edit.ts
index 9d6deb07e18..d77131b310b 100644
--- a/web/src/message_edit.ts
+++ b/web/src/message_edit.ts
@@ -106,11 +106,7 @@ export let notify_old_thread_default = false;
export let notify_new_thread_default = true;
export function is_topic_editable(message: Message, edit_limit_seconds_buffer = 0): boolean {
- if (!is_message_editable_ignoring_permissions(message)) {
- return false;
- }
-
- if (message.type !== "stream") {
+ if (!is_message_editable_ignoring_permissions(message) || message.type !== "stream") {
return false;
}
@@ -197,19 +193,12 @@ export function is_message_editable_ignoring_permissions(message: Message): bool
}
export function is_content_editable(message: Message, edit_limit_seconds_buffer = 0): boolean {
- if (!is_message_editable_ignoring_permissions(message)) {
- return false;
- }
-
- if (!realm.realm_allow_message_editing) {
- return false;
- }
-
- if (!message.sent_by_me) {
- return false;
- }
-
- if (is_widget_message(message)) {
+ if (
+ !is_message_editable_ignoring_permissions(message) ||
+ !realm.realm_allow_message_editing ||
+ !message.sent_by_me ||
+ is_widget_message(message)
+ ) {
return false;
}
@@ -217,15 +206,12 @@ export function is_content_editable(message: Message, edit_limit_seconds_buffer
return false;
}
- if (realm.realm_message_content_edit_limit_seconds === null) {
- return true;
- }
-
if (
+ realm.realm_message_content_edit_limit_seconds === null ||
realm.realm_message_content_edit_limit_seconds +
edit_limit_seconds_buffer +
(message.timestamp - Date.now() / 1000) >
- 0
+ 0
) {
return true;
}
@@ -241,11 +227,7 @@ export function remaining_content_edit_time(message: Message): number {
}
export function is_stream_editable(message: Message, edit_limit_seconds_buffer = 0): boolean {
- if (!is_message_editable_ignoring_permissions(message)) {
- return false;
- }
-
- if (message.type !== "stream") {
+ if (!is_message_editable_ignoring_permissions(message) || message.type !== "stream") {
return false;
}
diff --git a/web/src/message_fetch.ts b/web/src/message_fetch.ts
index 27aad499862..798de76127e 100644
--- a/web/src/message_fetch.ts
+++ b/web/src/message_fetch.ts
@@ -802,11 +802,10 @@ export function initialize(finished_initial_fetch: () => void): void {
// Since we backfill a lot more messages here compared to rendered message list,
// we can try populating them if we can do so locally.
for (const msg_list_data of message_list_data_cache.all()) {
- if (msg_list_data === recent_view_messages_data) {
- continue;
- }
-
- if (!msg_list_data.filter.can_apply_locally()) {
+ if (
+ msg_list_data === recent_view_messages_data ||
+ !msg_list_data.filter.can_apply_locally()
+ ) {
continue;
}
diff --git a/web/src/message_notifications.ts b/web/src/message_notifications.ts
index 48f64ee2ebd..4a473054f08 100644
--- a/web/src/message_notifications.ts
+++ b/web/src/message_notifications.ts
@@ -325,11 +325,7 @@ export function should_send_desktop_notification(
return true;
}
- if (alert_words.notifies(message)) {
- return true;
- }
-
- if (message.mentioned_me_directly) {
+ if (alert_words.notifies(message) || message.mentioned_me_directly) {
return true;
}
@@ -397,11 +393,7 @@ export function should_send_audible_notification(
return true;
}
- if (alert_words.notifies(message)) {
- return true;
- }
-
- if (message.mentioned_me_directly) {
+ if (alert_words.notifies(message) || message.mentioned_me_directly) {
return true;
}
diff --git a/web/src/message_store.ts b/web/src/message_store.ts
index 24a97406f00..5bc32c288d3 100644
--- a/web/src/message_store.ts
+++ b/web/src/message_store.ts
@@ -724,10 +724,7 @@ function remove_message_from_topic_links(message_id: number): void {
const inert_template = new DOMParser().parseFromString("", "text/html").createElement("template");
export function save_topic_links(message: Message): void {
- if (message.type !== "stream") {
- return;
- }
- if (muted_users.is_user_muted(message.sender_id)) {
+ if (message.type !== "stream" || muted_users.is_user_muted(message.sender_id)) {
return;
}
// Parsing HTML is expensive, and most messages have no narrow links.
@@ -768,10 +765,7 @@ export function save_topic_links(message: Message): void {
}
if (to_message_id !== undefined) {
const to_message = get(to_message_id);
- if (to_message === undefined) {
- continue;
- }
- if (muted_users.is_user_muted(to_message.sender_id)) {
+ if (to_message === undefined || muted_users.is_user_muted(to_message.sender_id)) {
continue;
}
}
diff --git a/web/src/messages_overlay_ui.ts b/web/src/messages_overlay_ui.ts
index c4f2b2fdc74..149aff256f8 100644
--- a/web/src/messages_overlay_ui.ts
+++ b/web/src/messages_overlay_ui.ts
@@ -248,10 +248,7 @@ function scroll_toward_visible(
}
function scroll_to_element($element: JQuery, context: Context): void {
- if ($element[0] === undefined) {
- return;
- }
- if ($element[0].firstElementChild === null) {
+ if ($element[0] === undefined || $element[0].firstElementChild === null) {
return;
}
assert($element[0].firstElementChild instanceof HTMLElement);
diff --git a/web/src/modals.ts b/web/src/modals.ts
index 122701e47ae..98a4980caf0 100644
--- a/web/src/modals.ts
+++ b/web/src/modals.ts
@@ -158,11 +158,7 @@ export function open(
});
$micromodal.find(".modal__overlay").on("click", (e) => {
- if (!$(e.target).is(".modal__overlay")) {
- return;
- }
-
- if ($(e.target).hasClass("ignore-overlay-click")) {
+ if (!$(e.target).is(".modal__overlay") || $(e.target).hasClass("ignore-overlay-click")) {
return;
}
diff --git a/web/src/poll_widget.ts b/web/src/poll_widget.ts
index 90c35f30ca5..dc3614cb77e 100644
--- a/web/src/poll_widget.ts
+++ b/web/src/poll_widget.ts
@@ -169,11 +169,7 @@ export function render({
const option = $poll_option_input.val()!.trim();
const options = poll_data.get_widget_data().options;
- if (poll_data.is_option_present(options, option)) {
- return;
- }
-
- if (option === "") {
+ if (poll_data.is_option_present(options, option) || option === "") {
return;
}
diff --git a/web/src/popover_menus_data.ts b/web/src/popover_menus_data.ts
index 7fd3b95622a..9944ff54caf 100644
--- a/web/src/popover_menus_data.ts
+++ b/web/src/popover_menus_data.ts
@@ -291,10 +291,7 @@ export function get_actions_popover_content_context(
const should_display_remind_me_option = not_spectator;
const should_display_message_report_option = (): boolean => {
- if (page_params.is_spectator) {
- return false;
- }
- if (realm.realm_moderation_request_channel_id === -1) {
+ if (page_params.is_spectator || realm.realm_moderation_request_channel_id === -1) {
return false;
}
diff --git a/web/src/portico/showroom.ts b/web/src/portico/showroom.ts
index 1dc676c17e7..58a5c57c301 100644
--- a/web/src/portico/showroom.ts
+++ b/web/src/portico/showroom.ts
@@ -471,10 +471,7 @@ $(window).on("load", () => {
const solid_button = current_banner.buttons.find(
(button) => button.variant === "solid",
);
- if (solid_button === undefined) {
- return;
- }
- if (!solid_button.icon) {
+ if (!solid_button?.icon) {
return;
}
solid_button.icon = this.value;
@@ -561,10 +558,7 @@ $(window).on("load", () => {
const subtle_button = current_banner.buttons.find(
(button) => button.variant === "subtle",
);
- if (subtle_button === undefined) {
- return;
- }
- if (!subtle_button.icon) {
+ if (!subtle_button?.icon) {
return;
}
subtle_button.icon = this.value;
@@ -649,10 +643,7 @@ $(window).on("load", () => {
"change",
function () {
const text_button = current_banner.buttons.find((button) => button.variant === "text");
- if (text_button === undefined) {
- return;
- }
- if (!text_button.icon) {
+ if (!text_button?.icon) {
return;
}
text_button.icon = this.value;
diff --git a/web/src/reactions.ts b/web/src/reactions.ts
index 574215b8c52..d8a2b51df9f 100644
--- a/web/src/reactions.ts
+++ b/web/src/reactions.ts
@@ -500,11 +500,7 @@ export let remove_reaction = (event: ReactionEvent): void => {
const clean_reaction_object = message.clean_reactions.get(local_id);
- if (!clean_reaction_object) {
- return;
- }
-
- if (!clean_reaction_object.user_ids.includes(user_id)) {
+ if (!clean_reaction_object?.user_ids.includes(user_id)) {
return;
}
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.ts
index 45bb410285f..402667a4abc 100644
--- a/web/src/recent_view_ui.ts
+++ b/web/src/recent_view_ui.ts
@@ -143,10 +143,10 @@ export function set_hide_other_views(callback: () => void): void {
const ORIGINAL_ICON_CLASS_DATA_ATTR = "data-vdots-original-icon-class";
function swap_visibility_icon_to_vdots($icon: JQuery): void {
- if ($icon.hasClass("recent-view-row-topic-menu")) {
- return;
- }
- if ($icon.attr(ORIGINAL_ICON_CLASS_DATA_ATTR) !== undefined) {
+ if (
+ $icon.hasClass("recent-view-row-topic-menu") ||
+ $icon.attr(ORIGINAL_ICON_CLASS_DATA_ATTR) !== undefined
+ ) {
return;
}
const icon_element = $icon.get(0);
@@ -1184,10 +1184,7 @@ export function bulk_inplace_rerender(row_keys: string[]): void {
}
export let inplace_rerender = (topic_key: string, is_bulk_rerender?: boolean): boolean => {
- if (!recent_view_util.is_visible()) {
- return false;
- }
- if (!recent_view_data.conversations.has(topic_key)) {
+ if (!recent_view_util.is_visible() || !recent_view_data.conversations.has(topic_key)) {
return false;
}
diff --git a/web/src/scheduled_messages_overlay_ui.ts b/web/src/scheduled_messages_overlay_ui.ts
index 5242e98a236..77bbed48421 100644
--- a/web/src/scheduled_messages_overlay_ui.ts
+++ b/web/src/scheduled_messages_overlay_ui.ts
@@ -179,10 +179,8 @@ export function remove_scheduled_message_id(scheduled_msg_id: number): void {
export function initialize(): void {
$("body").on("click", ".scheduled-message-row .restore-overlay-message", (e) => {
- if (mouse_drag.is_drag(e)) {
- return;
- }
if (
+ mouse_drag.is_drag(e) ||
messages_overlay_ui.handle_overlay_media_click(
e,
"scheduled",
diff --git a/web/src/search_suggestion.ts b/web/src/search_suggestion.ts
index 75ea9f5ab8d..6a57935442b 100644
--- a/web/src/search_suggestion.ts
+++ b/web/src/search_suggestion.ts
@@ -486,11 +486,10 @@ function get_group_suggestions(
// operand (not including the last part).
const person_matcher = people.build_person_matcher(new_query);
let persons = people.filter_all_persons((person) => {
- if (person.user_id === people.my_current_user_id()) {
- return false;
- }
-
- if (existing_user_ids.includes(person.user_id)) {
+ if (
+ person.user_id === people.my_current_user_id() ||
+ existing_user_ids.includes(person.user_id)
+ ) {
return false;
}
return new_query === "" || person_matcher(person);
diff --git a/web/src/settings_exports.ts b/web/src/settings_exports.ts
index 719f960545e..18d6cd31775 100644
--- a/web/src/settings_exports.ts
+++ b/web/src/settings_exports.ts
@@ -600,11 +600,7 @@ export function remove_export_consent_data_and_redraw(user_id: number): void {
}
export function update_export_consent_data_and_redraw(export_consent: ExportConsent): void {
- if (!meta.loaded) {
- return;
- }
-
- if (maybe_store_export_consent_data_and_return(export_consent)) {
+ if (!meta.loaded || maybe_store_export_consent_data_and_return(export_consent)) {
return;
}
diff --git a/web/src/stream_data.ts b/web/src/stream_data.ts
index 7015b1053af..d93c5e0bbbc 100644
--- a/web/src/stream_data.ts
+++ b/web/src/stream_data.ts
@@ -590,11 +590,7 @@ export function has_metadata_access(sub: StreamSubscription): boolean {
return true;
}
- if (sub.subscribed) {
- return true;
- }
-
- if (can_administer_channel(sub)) {
+ if (sub.subscribed || can_administer_channel(sub)) {
return true;
}
@@ -820,11 +816,10 @@ export function can_subscribe_others(sub: StreamSubscription): boolean {
return false;
}
- if (settings_data.can_subscribe_others_to_all_accessible_streams()) {
- return true;
- }
-
- if (can_administer_channel(sub)) {
+ if (
+ settings_data.can_subscribe_others_to_all_accessible_streams() ||
+ can_administer_channel(sub)
+ ) {
return true;
}
@@ -894,11 +889,7 @@ export let can_post_messages_in_stream = function (
stream: StreamSubscription,
sender_id: number = current_user.user_id,
): boolean {
- if (stream.is_archived) {
- return false;
- }
-
- if (page_params.is_spectator) {
+ if (stream.is_archived || page_params.is_spectator) {
return false;
}
@@ -996,11 +987,7 @@ export function is_topic_creation_enabled(stream_id: number | undefined): boolea
}
export function user_can_move_messages_out_of_channel(stream: StreamSubscription): boolean {
- if (page_params.is_spectator) {
- return false;
- }
-
- if (stream.is_archived) {
+ if (page_params.is_spectator || stream.is_archived) {
return false;
}
@@ -1025,11 +1012,7 @@ export function user_can_move_messages_out_of_channel(stream: StreamSubscription
}
export function user_can_move_messages_within_channel(stream: StreamSubscription): boolean {
- if (page_params.is_spectator) {
- return false;
- }
-
- if (stream.is_archived) {
+ if (page_params.is_spectator || stream.is_archived) {
return false;
}
diff --git a/web/src/stream_settings_ui.ts b/web/src/stream_settings_ui.ts
index 93f28c72f36..805fb61e50e 100644
--- a/web/src/stream_settings_ui.ts
+++ b/web/src/stream_settings_ui.ts
@@ -275,11 +275,10 @@ export function update_channel_folder(sub: StreamSubscription, folder_id: number
}
export function update_channel_folder_name(folder_id: number): void {
- if (!overlays.streams_open()) {
- return;
- }
-
- if ($("#subscription_overlay .nothing-selected").css("display") !== "none") {
+ if (
+ !overlays.streams_open() ||
+ $("#subscription_overlay .nothing-selected").css("display") !== "none"
+ ) {
return;
}
diff --git a/web/src/user_groups.ts b/web/src/user_groups.ts
index 141988158e7..2beb82ddb92 100644
--- a/web/src/user_groups.ts
+++ b/web/src/user_groups.ts
@@ -455,11 +455,7 @@ export function check_group_can_be_subgroup(
}
const already_subgroup_ids = target_user_group.direct_subgroup_ids;
- if (subgroup.id === target_user_group.id) {
- return false;
- }
-
- if (already_subgroup_ids.has(subgroup.id)) {
+ if (subgroup.id === target_user_group.id || already_subgroup_ids.has(subgroup.id)) {
return false;
}
diff --git a/web/src/vdom.ts b/web/src/vdom.ts
index 7b7e38c9f5d..263bfbd21a3 100644
--- a/web/src/vdom.ts
+++ b/web/src/vdom.ts
@@ -30,11 +30,7 @@ export function eq_array<T>(
return true;
}
- if (a === undefined || b === undefined) {
- return false;
- }
-
- if (a.length !== b.length) {
+ if (a === undefined || b === undefined || a.length !== b.length) {
return false;
}