Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/no-lonely-if.
Anders Kaseorg2f804157561b
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.jsindex f791f810dba..7508048e62e 100644--- a/static/js/click_handlers.js+++ b/static/js/click_handlers.js@@ -46,10 +46,8 @@ exports.initialize = function () {// Later we check whether after MS_DELAY the user is still// long touching the same message as it can be possible that// user touched another message within MS_DELAY period.- if (meta.touchdown === true && !meta.invalid) {- if (id === meta.current_target) {- $(this).trigger("longtap");- }+ if (meta.touchdown === true && !meta.invalid && id === meta.current_target) {+ $(this).trigger("longtap");}}, MS_DELAY);});diff --git a/static/js/compose_ui.js b/static/js/compose_ui.jsindex 4b85a59df9e..42c34c8a369 100644--- a/static/js/compose_ui.js+++ b/static/js/compose_ui.js@@ -19,13 +19,15 @@ exports.smart_insert = function (textarea, syntax) {const before_str = textarea.val().slice(0, pos);const after_str = textarea.val().slice(pos);- if (pos > 0) {+ if (+ pos > 0 &&// If there isn't space either at the end of the content// before the insert or (unlikely) at the start of the syntax,// add one.- if (!is_space(before_str.slice(-1)) && !is_space(syntax[0])) {- syntax = " " + syntax;- }+ !is_space(before_str.slice(-1)) &&+ !is_space(syntax[0])+ ) {+ syntax = " " + syntax;}// If there isn't whitespace either at the end of the syntax or thediff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.jsindex 543efe71c73..aa746b55b89 100644--- a/static/js/composebox_typeahead.js+++ b/static/js/composebox_typeahead.js@@ -227,12 +227,13 @@ function handle_keydown(e) {function handle_keyup(e) {const code = e.keyCode || e.which;- if (code === 13 || (code === 9 && !e.shiftKey)) {+ if (// Enter key or Tab key- if (nextFocus) {- nextFocus.trigger("focus");- nextFocus = false;- }+ (code === 13 || (code === 9 && !e.shiftKey)) &&+ nextFocus+ ) {+ nextFocus.trigger("focus");+ nextFocus = false;}}diff --git a/static/js/drafts.js b/static/js/drafts.jsindex 5e42f0097ee..1cffbabbd7b 100644--- a/static/js/drafts.js+++ b/static/js/drafts.js@@ -473,30 +473,28 @@ exports.drafts_handle_events = function (e, event_key) {const focused_draft_id = row_with_focus().data("draft-id");// Allows user to delete drafts with Backspace- if (event_key === "backspace" || event_key === "delete") {- if (focused_draft_id !== undefined) {- const draft_row = row_with_focus();- const next_draft_row = row_after_focus();- const prev_draft_row = row_before_focus();- let draft_to_be_focused_id;-- // Try to get the next draft in the list and 'focus' it- // Use previous draft as a fallback- if (next_draft_row[0] !== undefined) {- draft_to_be_focused_id = next_draft_row.data("draft-id");- } else if (prev_draft_row[0] !== undefined) {- draft_to_be_focused_id = prev_draft_row.data("draft-id");- }-- const new_focus_element = document.querySelectorAll(- '[data-draft-id="' + draft_to_be_focused_id + '"]',- );- if (new_focus_element[0] !== undefined) {- activate_element(new_focus_element[0].children[0]);- }+ if ((event_key === "backspace" || event_key === "delete") && focused_draft_id !== undefined) {+ const draft_row = row_with_focus();+ const next_draft_row = row_after_focus();+ const prev_draft_row = row_before_focus();+ let draft_to_be_focused_id;++ // Try to get the next draft in the list and 'focus' it+ // Use previous draft as a fallback+ if (next_draft_row[0] !== undefined) {+ draft_to_be_focused_id = next_draft_row.data("draft-id");+ } else if (prev_draft_row[0] !== undefined) {+ draft_to_be_focused_id = prev_draft_row.data("draft-id");+ }- remove_draft(draft_row);+ const new_focus_element = document.querySelectorAll(+ '[data-draft-id="' + draft_to_be_focused_id + '"]',+ );+ if (new_focus_element[0] !== undefined) {+ activate_element(new_focus_element[0].children[0]);}++ remove_draft(draft_row);}// This handles when pressing Enter while looking at drafts.diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.jsindex 190eb01a5d4..b8707a7d0cf 100644--- a/static/js/emoji_picker.js+++ b/static/js/emoji_picker.js@@ -512,30 +512,32 @@ exports.navigate = function (event_name, e) {function process_keypress(e) {const is_filter_focused = $(".emoji-popover-filter").is(":focus");const pressed_key = e.which;- if (!is_filter_focused && pressed_key !== 58) {+ if (+ !is_filter_focused &&// ':' => 58, is a hotkey for toggling reactions popover.- if ((pressed_key >= 32 && pressed_key <= 126) || pressed_key === 8) {- // Handle only printable characters or Backspace.- e.preventDefault();- e.stopPropagation();-- const emoji_filter = $(".emoji-popover-filter");- const old_query = emoji_filter.val();- let new_query = "";-- if (pressed_key === 8) {- // Handles Backspace.- new_query = old_query.slice(0, -1);- } else {- // Handles any printable character.- const key_str = String.fromCharCode(e.which);- new_query = old_query + key_str;- }+ pressed_key !== 58 &&+ ((pressed_key >= 32 && pressed_key <= 126) || pressed_key === 8)+ ) {+ // Handle only printable characters or Backspace.+ e.preventDefault();+ e.stopPropagation();- emoji_filter.val(new_query);- change_focus_to_filter();- filter_emojis();+ const emoji_filter = $(".emoji-popover-filter");+ const old_query = emoji_filter.val();+ let new_query = "";++ if (pressed_key === 8) {+ // Handles Backspace.+ new_query = old_query.slice(0, -1);+ } else {+ // Handles any printable character.+ const key_str = String.fromCharCode(e.which);+ new_query = old_query + key_str;}++ emoji_filter.val(new_query);+ change_focus_to_filter();+ filter_emojis();}}diff --git a/static/js/floating_recipient_bar.js b/static/js/floating_recipient_bar.jsindex a045a993176..5b986984c1e 100644--- a/static/js/floating_recipient_bar.js+++ b/static/js/floating_recipient_bar.js@@ -58,15 +58,17 @@ exports.first_visible_message = function (bar) {// Important: This will break if we ever have things that are// not message rows inside a recipient_row block.message = message.next(".message_row");- if (message.length > 0 && result) {+ if (+ message.length > 0 &&+ result &&// Before returning a result, we check whether the next// message's top is actually below the bottom of the// floating recipient bar; this is different from the// bottom of our current message because there may be a// between-messages date separator row in between.- if (top_offset(message) < frb_bottom - date_bar_height_offset) {- result = message;- }+ top_offset(message) < frb_bottom - date_bar_height_offset+ ) {+ result = message;}if (result) {return result;diff --git a/static/js/hashchange.js b/static/js/hashchange.jsindex 838384334f8..52b61123606 100644--- a/static/js/hashchange.js+++ b/static/js/hashchange.js@@ -150,37 +150,35 @@ function do_hashchange_overlay(old_hash) {//// In most situations we skip by this logic and load// the new overlay.- if (coming_from_overlay) {- if (base === old_base) {- if (base === "streams") {- subs.change_state(section);- return;- }+ if (coming_from_overlay && base === old_base) {+ if (base === "streams") {+ subs.change_state(section);+ return;+ }- if (base === "settings") {- if (!section) {- // We may be on a really old browser or somebody- // hand-typed a hash.- blueslip.warn("missing section for settings");- }- settings_panel_menu.normal_settings.activate_section_or_default(section);- return;+ if (base === "settings") {+ if (!section) {+ // We may be on a really old browser or somebody+ // hand-typed a hash.+ blueslip.warn("missing section for settings");}+ settings_panel_menu.normal_settings.activate_section_or_default(section);+ return;+ }- if (base === "organization") {- if (!section) {- // We may be on a really old browser or somebody- // hand-typed a hash.- blueslip.warn("missing section for organization");- }- settings_panel_menu.org_settings.activate_section_or_default(section);- return;+ if (base === "organization") {+ if (!section) {+ // We may be on a really old browser or somebody+ // hand-typed a hash.+ blueslip.warn("missing section for organization");}-- // TODO: handle other cases like internal settings- // changes.+ settings_panel_menu.org_settings.activate_section_or_default(section);return;}++ // TODO: handle other cases like internal settings+ // changes.+ return;}// It's not super likely that an overlay is already open,diff --git a/static/js/hotkey.js b/static/js/hotkey.jsindex 2bce02770c2..ff8d62e31e8 100644--- a/static/js/hotkey.js+++ b/static/js/hotkey.js@@ -559,18 +559,14 @@ exports.process_hotkey = function (e, hotkey) {return false;}- if (event_name === "up_arrow") {- if (list_util.inside_list(e)) {- list_util.go_up(e);- return true;- }+ if (event_name === "up_arrow" && list_util.inside_list(e)) {+ list_util.go_up(e);+ return true;}- if (event_name === "down_arrow") {- if (list_util.inside_list(e)) {- list_util.go_down(e);- return true;- }+ if (event_name === "down_arrow" && list_util.inside_list(e)) {+ list_util.go_down(e);+ return true;}if (menu_dropdown_hotkeys.has(event_name)) {@@ -618,11 +614,9 @@ exports.process_hotkey = function (e, hotkey) {// The next two sections date back to 00445c84 and are Mac/Chrome-specific,// and they should possibly be eliminated in favor of keeping standard// browser behavior.- if (event_name === "backspace") {- if ($("#compose-send-button").is(":focus")) {- // Ignore Backspace; don't navigate back a page.- return true;- }+ if (event_name === "backspace" && $("#compose-send-button").is(":focus")) {+ // Ignore Backspace; don't navigate back a page.+ return true;}if (event_name === "narrow_to_compose_target") {diff --git a/static/js/input_pill.js b/static/js/input_pill.jsindex 76bf3becfad..a62fae7aef9 100644--- a/static/js/input_pill.js+++ b/static/js/input_pill.js@@ -282,10 +282,8 @@ exports.create = function (opts) {// should switch to focus the last pill in the list.// the rest of the events then will be taken care of in the function// below that handles events on the ".pill" class.- if (char === KEY.LEFT_ARROW) {- if (window.getSelection().anchorOffset === 0) {- store.$parent.find(".pill").last().trigger("focus");- }+ if (char === KEY.LEFT_ARROW && window.getSelection().anchorOffset === 0) {+ store.$parent.find(".pill").last().trigger("focus");}// Typing of the comma is prevented if the last field doesn't validate,diff --git a/static/js/localstorage.js b/static/js/localstorage.jsindex dd09ff76029..188d5b53505 100644--- a/static/js/localstorage.js+++ b/static/js/localstorage.js@@ -35,14 +35,14 @@ const ls = {let data = localStorage.getItem(key);data = ls.parseJSON(data);- if (data) {- if (data.__valid) {- // JSON forms of data with `Infinity` turns into `null`,- // so if null then it hasn't expired since nothing was specified.- if (!ls.isExpired(data.expires) || data.expires === null) {- return data;- }- }+ if (+ data &&+ data.__valid &&+ // JSON forms of data with `Infinity` turns into `null`,+ // so if null then it hasn't expired since nothing was specified.+ (!ls.isExpired(data.expires) || data.expires === null)+ ) {+ return data;}return undefined;diff --git a/static/js/message_events.js b/static/js/message_events.jsindex e4b40edc0be..6dfeb0815ca 100644--- a/static/js/message_events.js+++ b/static/js/message_events.js@@ -168,14 +168,16 @@ exports.update_messages = function update_messages(events) {// The event.message_ids received from the server are not in sorted order.event_messages.sort((a, b) => a.id - b.id);- if (going_forward_change && stream_name && compose_stream_name) {- if (stream_name.toLowerCase() === compose_stream_name.toLowerCase()) {- if (orig_topic === compose_state.topic()) {- changed_compose = true;- compose_state.topic(new_topic);- compose_fade.set_focused_recipient("stream");- }- }+ if (+ going_forward_change &&+ stream_name &&+ compose_stream_name &&+ stream_name.toLowerCase() === compose_stream_name.toLowerCase() &&+ orig_topic === compose_state.topic()+ ) {+ changed_compose = true;+ compose_state.topic(new_topic);+ compose_fade.set_focused_recipient("stream");}for (const msg of event_messages) {@@ -224,7 +226,8 @@ exports.update_messages = function update_messages(events) {});}- if (going_forward_change) {+ if (+ going_forward_change &&// This logic is a bit awkward. What we're trying to// accomplish is two things://@@ -238,45 +241,45 @@ exports.update_messages = function update_messages(events) {//// Code further down takes care of the actual rerendering of// messages within a narrow.- if (selection_changed_topic) {- if (current_filter && current_filter.has_topic(stream_name, orig_topic)) {- let new_filter = current_filter;- if (new_filter && stream_changed) {- // TODO: This logic doesn't handle the- // case where we're a guest user and the- // message moves to a stream we cannot- // access, which would cause the- // stream_data lookup here to fail.- //- // The fix is likely somewhat involved, so punting for now.- const new_stream_name = stream_data.get_sub_by_id(new_stream_id).name;- new_filter = new_filter.filter_with_new_params({- operator: "stream",- operand: new_stream_name,- });- changed_narrow = true;- }-- if (new_filter && topic_edited) {- new_filter = new_filter.filter_with_new_params({- operator: "topic",- operand: new_topic,- });- changed_narrow = true;- }- // NOTE: We should always be changing narrows after we finish- // updating the local data and UI. This avoids conflict- // with data fetched from the server (which is already updated)- // when we move to new narrow and what data is locally available.- if (changed_narrow) {- const operators = new_filter.operators();- const opts = {- trigger: "stream/topic change",- then_select_id: current_selected_id,- };- narrow.activate(operators, opts);- }- }+ selection_changed_topic &&+ current_filter &&+ current_filter.has_topic(stream_name, orig_topic)+ ) {+ let new_filter = current_filter;+ if (new_filter && stream_changed) {+ // TODO: This logic doesn't handle the+ // case where we're a guest user and the+ // message moves to a stream we cannot+ // access, which would cause the+ // stream_data lookup here to fail.+ //+ // The fix is likely somewhat involved, so punting for now.+ const new_stream_name = stream_data.get_sub_by_id(new_stream_id).name;+ new_filter = new_filter.filter_with_new_params({+ operator: "stream",+ operand: new_stream_name,+ });+ changed_narrow = true;+ }++ if (new_filter && topic_edited) {+ new_filter = new_filter.filter_with_new_params({+ operator: "topic",+ operand: new_topic,+ });+ changed_narrow = true;+ }+ // NOTE: We should always be changing narrows after we finish+ // updating the local data and UI. This avoids conflict+ // with data fetched from the server (which is already updated)+ // when we move to new narrow and what data is locally available.+ if (changed_narrow) {+ const operators = new_filter.operators();+ const opts = {+ trigger: "stream/topic change",+ then_select_id: current_selected_id,+ };+ narrow.activate(operators, opts);}}diff --git a/static/js/message_util.js b/static/js/message_util.jsindex e14a3eb8f41..4f879b3d1b5 100644--- a/static/js/message_util.js+++ b/static/js/message_util.js@@ -69,10 +69,8 @@ exports.get_messages_in_topic = function (stream_id, topic) {exports.get_max_message_id_in_stream = function (stream_id) {let max_message_id = 0;for (const msg of message_list.all.all_messages()) {- if (msg.type === "stream" && msg.stream_id === stream_id) {- if (msg.id > max_message_id) {- max_message_id = msg.id;- }+ if (msg.type === "stream" && msg.stream_id === stream_id && msg.id > max_message_id) {+ max_message_id = msg.id;}}return max_message_id;diff --git a/static/js/panels.js b/static/js/panels.jsindex 418c412e272..650d7c5796a 100644--- a/static/js/panels.js+++ b/static/js/panels.js@@ -32,10 +32,8 @@ const get_step = function ($process) {function should_show_notifications(ls) {// if the user said to never show banner on this computer again, it will// be stored as `true` so we want to negate that.- if (localstorage.supported()) {- if (ls.get("dontAskForNotifications") === true) {- return false;- }+ if (localstorage.supported() && ls.get("dontAskForNotifications") === true) {+ return false;}return (diff --git a/static/js/portico/dev-login.js b/static/js/portico/dev-login.jsindex d32fadf1924..10c74a2abbe 100644--- a/static/js/portico/dev-login.js+++ b/static/js/portico/dev-login.js@@ -3,15 +3,13 @@$(() => {// This code will be executed when the user visits /login and// dev_login.html is rendered.- if ($("[data-page-id='dev-login']").length > 0) {- if (window.location.hash.slice(0, 1) === "#") {- /* We append the location.hash to the input field with name next so that URL can be+ if ($("[data-page-id='dev-login']").length > 0 && window.location.hash.slice(0, 1) === "#") {+ /* We append the location.hash to the input field with name next so that URL can bepreserved after user is logged in. See this:https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */- $("input[name='next']").each(function () {- const new_value = $(this).attr("value") + window.location.hash;- $(this).attr("value", new_value);- });- }+ $("input[name='next']").each(function () {+ const new_value = $(this).attr("value") + window.location.hash;+ $(this).attr("value", new_value);+ });}});diff --git a/static/js/portico/signup.js b/static/js/portico/signup.jsindex b8bccb95a9a..592b22a5244 100644--- a/static/js/portico/signup.js+++ b/static/js/portico/signup.js@@ -95,23 +95,22 @@ $(() => {// Code in this block will be executed when the user visits /register// i.e. accounts_home.html is rendered.- if ($("[data-page-id='accounts-home']").length > 0) {- if (window.location.hash.slice(0, 1) === "#") {- document.email_form.action += window.location.hash;- }+ if (+ $("[data-page-id='accounts-home']").length > 0 &&+ window.location.hash.slice(0, 1) === "#"+ ) {+ document.email_form.action += window.location.hash;}// Code in this block will be executed when the user is at login page// i.e. login.html is rendered.- if ($("[data-page-id='login-page']").length > 0) {- if (window.location.hash.slice(0, 1) === "#") {- /* We append the location.hash to the formaction so that URL can be- preserved after user is logged in. See this:- https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */- const email_formaction = $("#login_form").attr("action");- $("#login_form").attr("action", email_formaction + "/" + window.location.hash);- $(".social_login_form input[name='next']").attr("value", "/" + window.location.hash);- }+ if ($("[data-page-id='login-page']").length > 0 && window.location.hash.slice(0, 1) === "#") {+ /* We append the location.hash to the formaction so that URL can be+ preserved after user is logged in. See this:+ https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */+ const email_formaction = $("#login_form").attr("action");+ $("#login_form").attr("action", email_formaction + "/" + window.location.hash);+ $(".social_login_form input[name='next']").attr("value", "/" + window.location.hash);}$("#send_confirm").validate({diff --git a/static/js/presence.js b/static/js/presence.jsindex 07e229a92ea..03c9a22eebb 100644--- a/static/js/presence.js+++ b/static/js/presence.js@@ -124,16 +124,12 @@ exports.update_info_from_event = function (user_id, info, server_timestamp) {raw.server_timestamp = server_timestamp;for (const rec of Object.values(info)) {- if (rec.status === "active") {- if (rec.timestamp > (raw.active_timestamp || 0)) {- raw.active_timestamp = rec.timestamp;- }+ if (rec.status === "active" && rec.timestamp > (raw.active_timestamp || 0)) {+ raw.active_timestamp = rec.timestamp;}- if (rec.status === "idle") {- if (rec.timestamp > (raw.idle_timestamp || 0)) {- raw.idle_timestamp = rec.timestamp;- }+ if (rec.status === "idle" && rec.timestamp > (raw.idle_timestamp || 0)) {+ raw.idle_timestamp = rec.timestamp;}}diff --git a/static/js/rtl.js b/static/js/rtl.jsindex 4ce56097242..642c9929855 100644--- a/static/js/rtl.js+++ b/static/js/rtl.js@@ -114,21 +114,19 @@ exports.get_direction = function (str) {// Extracting high and low surrogates and putting them together.// See https://en.wikipedia.org/wiki/UTF-16#Description or section 3 of https://tools.ietf.org/html/rfc2781.let ch = str.charCodeAt(i);- if (ch >= 0xd800 && ch < 0xe000) {- // 0xd800 <= ch < 0xe000- // ch is inside surrogate range.+ if (ch >= 0xd800 && ch < 0xdc00) {+ // 0xd800 <= ch < 0xdc00+ // ch is inside high surrogate range.// If it made a surrogate pair with the next character, put them together.// Otherwise, ignore the encoding error and leave it as it is.- if (ch < 0xdc00) {- const ch2 = i + 1 < str.length ? str.charCodeAt(i + 1) : 0;- if (ch2 >= 0xdc00 && ch2 < 0xe000) {- // 0xdc00 <= ch2 < 0xe000- // ch = ch & 0x3ff;- ch -= 0xd800;- // ch = 0x10000 | (ch << 10) | (ch2 & 0x3ff);- ch = 0x10000 + ch * 0x400 + (ch2 - 0xdc00);- i += 1;- }+ const ch2 = i + 1 < str.length ? str.charCodeAt(i + 1) : 0;+ if (ch2 >= 0xdc00 && ch2 < 0xe000) {+ // 0xdc00 <= ch2 < 0xe000+ // ch = ch & 0x3ff;+ ch -= 0xd800;+ // ch = 0x10000 | (ch << 10) | (ch2 & 0x3ff);+ ch = 0x10000 + ch * 0x400 + (ch2 - 0xdc00);+ i += 1;}}@@ -145,10 +143,8 @@ exports.get_direction = function (str) {if (isolations === 0) {return "rtl";}- } else if (bidi_class === "L") {- if (isolations === 0) {- return "ltr";- }+ } else if (bidi_class === "L" && isolations === 0) {+ return "ltr";}}return "ltr";diff --git a/static/js/search_suggestion.js b/static/js/search_suggestion.jsindex bd8e0b1379f..3eed811f9ff 100644--- a/static/js/search_suggestion.js+++ b/static/js/search_suggestion.js@@ -702,16 +702,17 @@ exports.get_search_result = function (base_query, query) {}}- if (!page_params.search_pills_enabled) {+ if (+ !page_params.search_pills_enabled &&// This is unique to the legacy search system. With pills// it is difficult to "suggest" a subset of operators,// and there's a more natural mechanism under that paradigm,// where the user just deletes one or more pills. So you// won't see this is in the new code.- if (attacher.result.length < max_items) {- const subset_suggestions = get_operator_subset_suggestions(search_operators);- attacher.concat(subset_suggestions);- }+ attacher.result.length < max_items+ ) {+ const subset_suggestions = get_operator_subset_suggestions(search_operators);+ attacher.concat(subset_suggestions);}return attacher.result.slice(0, max_items);diff --git a/static/js/settings_bots.js b/static/js/settings_bots.jsindex d3a494e2248..99f8ae4a375 100644--- a/static/js/settings_bots.js+++ b/static/js/settings_bots.js@@ -97,11 +97,9 @@ exports.render_bots = function () {user_owns_an_active_bot = user_owns_an_active_bot || elem.is_active;}- if (exports.can_create_new_bots()) {- if (!user_owns_an_active_bot) {- focus_tab.add_a_new_bot_tab();- return;- }+ if (exports.can_create_new_bots() && !user_owns_an_active_bot) {+ focus_tab.add_a_new_bot_tab();+ return;}if ($("#bots_lists_navbar .add-a-new-bot-tab").hasClass("active")) {diff --git a/static/js/stream_topic_history.js b/static/js/stream_topic_history.jsindex 423a4880e1e..43e00fcae7d 100644--- a/static/js/stream_topic_history.js+++ b/static/js/stream_topic_history.js@@ -154,12 +154,10 @@ class PerStreamHistory {const existing = this.topics.get(topic_name);- if (existing) {- if (!existing.historical) {- // Trust out local data more, since it- // maintains counts.- continue;- }+ if (existing && !existing.historical) {+ // Trust out local data more, since it+ // maintains counts.+ continue;}// If we get here, we are either finding out aboutdiff --git a/static/js/subs.js b/static/js/subs.jsindex 5c1f4443d08..7d51dd8818b 100644--- a/static/js/subs.js+++ b/static/js/subs.js@@ -343,11 +343,9 @@ exports.update_settings_for_unsubscribed = function (sub) {};function triage_stream(query, sub) {- if (query.subscribed_only) {+ if (query.subscribed_only && !sub.subscribed) {// reject non-subscribed streams- if (!sub.subscribed) {- return "rejected";- }+ return "rejected";}const search_terms = search_util.get_search_terms(query.input);diff --git a/static/js/timerender.js b/static/js/timerender.jsindex 5f606b326e0..5c652e5050b 100644--- a/static/js/timerender.js+++ b/static/js/timerender.js@@ -95,13 +95,15 @@ exports.last_seen_status_from_date = function (last_active_date, current_date) {if (days < 90) {return i18n.t("__days__ days ago", {days});- } else if (days > 90 && days < 365) {- if (current_date.getFullYear() === last_active_date.getFullYear()) {- // Online more than 90 days ago, in the same year- return i18n.t("__last_active_date__", {- last_active_date: last_active_date.toString("MMM\u00A0dd"),- });- }+ } else if (+ days > 90 &&+ days < 365 &&+ current_date.getFullYear() === last_active_date.getFullYear()+ ) {+ // Online more than 90 days ago, in the same year+ return i18n.t("__last_active_date__", {+ last_active_date: last_active_date.toString("MMM\u00A0dd"),+ });}return i18n.t("__last_active_date__", {last_active_date: last_active_date.toString("MMM\u00A0dd,\u00A0yyyy"),diff --git a/static/js/ui_init.js b/static/js/ui_init.jsindex 4f5373f244b..1802f3faab8 100644--- a/static/js/ui_init.js+++ b/static/js/ui_init.js@@ -74,10 +74,8 @@ exports.initialize_kitchen_sink_stuff = function () {if (message_viewport.at_top()) {navigate.up();}- } else if (delta > 0) {- if (message_viewport.at_bottom()) {- navigate.down();- }+ } else if (delta > 0 && message_viewport.at_bottom()) {+ navigate.down();}message_viewport.set_last_movement_direction(delta);