mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
eslint: Fix unicorn/no-lonely-if.
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v24.0.0/docs/rules/no-lonely-if.md Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
6acbcec39d
commit
2f80415756
@@ -46,11 +46,9 @@ exports.initialize = function () {
|
|||||||
// Later we check whether after MS_DELAY the user is still
|
// Later we check whether after MS_DELAY the user is still
|
||||||
// long touching the same message as it can be possible that
|
// long touching the same message as it can be possible that
|
||||||
// user touched another message within MS_DELAY period.
|
// user touched another message within MS_DELAY period.
|
||||||
if (meta.touchdown === true && !meta.invalid) {
|
if (meta.touchdown === true && !meta.invalid && id === meta.current_target) {
|
||||||
if (id === meta.current_target) {
|
|
||||||
$(this).trigger("longtap");
|
$(this).trigger("longtap");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, MS_DELAY);
|
}, MS_DELAY);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,16 @@ exports.smart_insert = function (textarea, syntax) {
|
|||||||
const before_str = textarea.val().slice(0, pos);
|
const before_str = textarea.val().slice(0, pos);
|
||||||
const after_str = textarea.val().slice(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
|
// If there isn't space either at the end of the content
|
||||||
// before the insert or (unlikely) at the start of the syntax,
|
// before the insert or (unlikely) at the start of the syntax,
|
||||||
// add one.
|
// add one.
|
||||||
if (!is_space(before_str.slice(-1)) && !is_space(syntax[0])) {
|
!is_space(before_str.slice(-1)) &&
|
||||||
|
!is_space(syntax[0])
|
||||||
|
) {
|
||||||
syntax = " " + syntax;
|
syntax = " " + syntax;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If there isn't whitespace either at the end of the syntax or the
|
// If there isn't whitespace either at the end of the syntax or the
|
||||||
// start of the content after the syntax, add one.
|
// start of the content after the syntax, add one.
|
||||||
|
|||||||
@@ -227,14 +227,15 @@ function handle_keydown(e) {
|
|||||||
function handle_keyup(e) {
|
function handle_keyup(e) {
|
||||||
const code = e.keyCode || e.which;
|
const code = e.keyCode || e.which;
|
||||||
|
|
||||||
if (code === 13 || (code === 9 && !e.shiftKey)) {
|
if (
|
||||||
// Enter key or Tab key
|
// Enter key or Tab key
|
||||||
if (nextFocus) {
|
(code === 13 || (code === 9 && !e.shiftKey)) &&
|
||||||
|
nextFocus
|
||||||
|
) {
|
||||||
nextFocus.trigger("focus");
|
nextFocus.trigger("focus");
|
||||||
nextFocus = false;
|
nextFocus = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
exports.split_at_cursor = function (query, input) {
|
exports.split_at_cursor = function (query, input) {
|
||||||
const cursor = input.caret();
|
const cursor = input.caret();
|
||||||
|
|||||||
@@ -473,8 +473,7 @@ exports.drafts_handle_events = function (e, event_key) {
|
|||||||
|
|
||||||
const focused_draft_id = row_with_focus().data("draft-id");
|
const focused_draft_id = row_with_focus().data("draft-id");
|
||||||
// Allows user to delete drafts with Backspace
|
// Allows user to delete drafts with Backspace
|
||||||
if (event_key === "backspace" || event_key === "delete") {
|
if ((event_key === "backspace" || event_key === "delete") && focused_draft_id !== undefined) {
|
||||||
if (focused_draft_id !== undefined) {
|
|
||||||
const draft_row = row_with_focus();
|
const draft_row = row_with_focus();
|
||||||
const next_draft_row = row_after_focus();
|
const next_draft_row = row_after_focus();
|
||||||
const prev_draft_row = row_before_focus();
|
const prev_draft_row = row_before_focus();
|
||||||
@@ -497,7 +496,6 @@ exports.drafts_handle_events = function (e, event_key) {
|
|||||||
|
|
||||||
remove_draft(draft_row);
|
remove_draft(draft_row);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// This handles when pressing Enter while looking at drafts.
|
// This handles when pressing Enter while looking at drafts.
|
||||||
// It restores draft that is focused.
|
// It restores draft that is focused.
|
||||||
|
|||||||
@@ -512,9 +512,12 @@ exports.navigate = function (event_name, e) {
|
|||||||
function process_keypress(e) {
|
function process_keypress(e) {
|
||||||
const is_filter_focused = $(".emoji-popover-filter").is(":focus");
|
const is_filter_focused = $(".emoji-popover-filter").is(":focus");
|
||||||
const pressed_key = e.which;
|
const pressed_key = e.which;
|
||||||
if (!is_filter_focused && pressed_key !== 58) {
|
if (
|
||||||
|
!is_filter_focused &&
|
||||||
// ':' => 58, is a hotkey for toggling reactions popover.
|
// ':' => 58, is a hotkey for toggling reactions popover.
|
||||||
if ((pressed_key >= 32 && pressed_key <= 126) || pressed_key === 8) {
|
pressed_key !== 58 &&
|
||||||
|
((pressed_key >= 32 && pressed_key <= 126) || pressed_key === 8)
|
||||||
|
) {
|
||||||
// Handle only printable characters or Backspace.
|
// Handle only printable characters or Backspace.
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -537,7 +540,6 @@ function process_keypress(e) {
|
|||||||
filter_emojis();
|
filter_emojis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
exports.emoji_select_tab = function (elt) {
|
exports.emoji_select_tab = function (elt) {
|
||||||
const scrolltop = elt.scrollTop();
|
const scrolltop = elt.scrollTop();
|
||||||
|
|||||||
@@ -58,16 +58,18 @@ exports.first_visible_message = function (bar) {
|
|||||||
// Important: This will break if we ever have things that are
|
// Important: This will break if we ever have things that are
|
||||||
// not message rows inside a recipient_row block.
|
// not message rows inside a recipient_row block.
|
||||||
message = message.next(".message_row");
|
message = message.next(".message_row");
|
||||||
if (message.length > 0 && result) {
|
if (
|
||||||
|
message.length > 0 &&
|
||||||
|
result &&
|
||||||
// Before returning a result, we check whether the next
|
// Before returning a result, we check whether the next
|
||||||
// message's top is actually below the bottom of the
|
// message's top is actually below the bottom of the
|
||||||
// floating recipient bar; this is different from the
|
// floating recipient bar; this is different from the
|
||||||
// bottom of our current message because there may be a
|
// bottom of our current message because there may be a
|
||||||
// between-messages date separator row in between.
|
// between-messages date separator row in between.
|
||||||
if (top_offset(message) < frb_bottom - date_bar_height_offset) {
|
top_offset(message) < frb_bottom - date_bar_height_offset
|
||||||
|
) {
|
||||||
result = message;
|
result = message;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,8 +150,7 @@ function do_hashchange_overlay(old_hash) {
|
|||||||
//
|
//
|
||||||
// In most situations we skip by this logic and load
|
// In most situations we skip by this logic and load
|
||||||
// the new overlay.
|
// the new overlay.
|
||||||
if (coming_from_overlay) {
|
if (coming_from_overlay && base === old_base) {
|
||||||
if (base === old_base) {
|
|
||||||
if (base === "streams") {
|
if (base === "streams") {
|
||||||
subs.change_state(section);
|
subs.change_state(section);
|
||||||
return;
|
return;
|
||||||
@@ -181,7 +180,6 @@ function do_hashchange_overlay(old_hash) {
|
|||||||
// changes.
|
// changes.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// It's not super likely that an overlay is already open,
|
// It's not super likely that an overlay is already open,
|
||||||
// but you can jump from /settings to /streams by using
|
// but you can jump from /settings to /streams by using
|
||||||
|
|||||||
@@ -559,19 +559,15 @@ exports.process_hotkey = function (e, hotkey) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event_name === "up_arrow") {
|
if (event_name === "up_arrow" && list_util.inside_list(e)) {
|
||||||
if (list_util.inside_list(e)) {
|
|
||||||
list_util.go_up(e);
|
list_util.go_up(e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (event_name === "down_arrow") {
|
if (event_name === "down_arrow" && list_util.inside_list(e)) {
|
||||||
if (list_util.inside_list(e)) {
|
|
||||||
list_util.go_down(e);
|
list_util.go_down(e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (menu_dropdown_hotkeys.has(event_name)) {
|
if (menu_dropdown_hotkeys.has(event_name)) {
|
||||||
if (popovers.actions_popped()) {
|
if (popovers.actions_popped()) {
|
||||||
@@ -618,12 +614,10 @@ exports.process_hotkey = function (e, hotkey) {
|
|||||||
// The next two sections date back to 00445c84 and are Mac/Chrome-specific,
|
// The next two sections date back to 00445c84 and are Mac/Chrome-specific,
|
||||||
// and they should possibly be eliminated in favor of keeping standard
|
// and they should possibly be eliminated in favor of keeping standard
|
||||||
// browser behavior.
|
// browser behavior.
|
||||||
if (event_name === "backspace") {
|
if (event_name === "backspace" && $("#compose-send-button").is(":focus")) {
|
||||||
if ($("#compose-send-button").is(":focus")) {
|
|
||||||
// Ignore Backspace; don't navigate back a page.
|
// Ignore Backspace; don't navigate back a page.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (event_name === "narrow_to_compose_target") {
|
if (event_name === "narrow_to_compose_target") {
|
||||||
narrow.to_compose_target();
|
narrow.to_compose_target();
|
||||||
|
|||||||
@@ -282,11 +282,9 @@ exports.create = function (opts) {
|
|||||||
// should switch to focus the last pill in the list.
|
// should switch to focus the last pill in the list.
|
||||||
// the rest of the events then will be taken care of in the function
|
// the rest of the events then will be taken care of in the function
|
||||||
// below that handles events on the ".pill" class.
|
// below that handles events on the ".pill" class.
|
||||||
if (char === KEY.LEFT_ARROW) {
|
if (char === KEY.LEFT_ARROW && window.getSelection().anchorOffset === 0) {
|
||||||
if (window.getSelection().anchorOffset === 0) {
|
|
||||||
store.$parent.find(".pill").last().trigger("focus");
|
store.$parent.find(".pill").last().trigger("focus");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Typing of the comma is prevented if the last field doesn't validate,
|
// Typing of the comma is prevented if the last field doesn't validate,
|
||||||
// as well as when the new pill is created.
|
// as well as when the new pill is created.
|
||||||
|
|||||||
@@ -35,15 +35,15 @@ const ls = {
|
|||||||
let data = localStorage.getItem(key);
|
let data = localStorage.getItem(key);
|
||||||
data = ls.parseJSON(data);
|
data = ls.parseJSON(data);
|
||||||
|
|
||||||
if (data) {
|
if (
|
||||||
if (data.__valid) {
|
data &&
|
||||||
|
data.__valid &&
|
||||||
// JSON forms of data with `Infinity` turns into `null`,
|
// JSON forms of data with `Infinity` turns into `null`,
|
||||||
// so if null then it hasn't expired since nothing was specified.
|
// so if null then it hasn't expired since nothing was specified.
|
||||||
if (!ls.isExpired(data.expires) || data.expires === null) {
|
(!ls.isExpired(data.expires) || data.expires === null)
|
||||||
|
) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -168,15 +168,17 @@ exports.update_messages = function update_messages(events) {
|
|||||||
// The event.message_ids received from the server are not in sorted order.
|
// The event.message_ids received from the server are not in sorted order.
|
||||||
event_messages.sort((a, b) => a.id - b.id);
|
event_messages.sort((a, b) => a.id - b.id);
|
||||||
|
|
||||||
if (going_forward_change && stream_name && compose_stream_name) {
|
if (
|
||||||
if (stream_name.toLowerCase() === compose_stream_name.toLowerCase()) {
|
going_forward_change &&
|
||||||
if (orig_topic === compose_state.topic()) {
|
stream_name &&
|
||||||
|
compose_stream_name &&
|
||||||
|
stream_name.toLowerCase() === compose_stream_name.toLowerCase() &&
|
||||||
|
orig_topic === compose_state.topic()
|
||||||
|
) {
|
||||||
changed_compose = true;
|
changed_compose = true;
|
||||||
compose_state.topic(new_topic);
|
compose_state.topic(new_topic);
|
||||||
compose_fade.set_focused_recipient("stream");
|
compose_fade.set_focused_recipient("stream");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const msg of event_messages) {
|
for (const msg of event_messages) {
|
||||||
if (msg === undefined) {
|
if (msg === undefined) {
|
||||||
@@ -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
|
// This logic is a bit awkward. What we're trying to
|
||||||
// accomplish is two things:
|
// accomplish is two things:
|
||||||
//
|
//
|
||||||
@@ -238,8 +241,10 @@ exports.update_messages = function update_messages(events) {
|
|||||||
//
|
//
|
||||||
// Code further down takes care of the actual rerendering of
|
// Code further down takes care of the actual rerendering of
|
||||||
// messages within a narrow.
|
// messages within a narrow.
|
||||||
if (selection_changed_topic) {
|
selection_changed_topic &&
|
||||||
if (current_filter && current_filter.has_topic(stream_name, orig_topic)) {
|
current_filter &&
|
||||||
|
current_filter.has_topic(stream_name, orig_topic)
|
||||||
|
) {
|
||||||
let new_filter = current_filter;
|
let new_filter = current_filter;
|
||||||
if (new_filter && stream_changed) {
|
if (new_filter && stream_changed) {
|
||||||
// TODO: This logic doesn't handle the
|
// TODO: This logic doesn't handle the
|
||||||
@@ -277,8 +282,6 @@ exports.update_messages = function update_messages(events) {
|
|||||||
narrow.activate(operators, opts);
|
narrow.activate(operators, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure messages that are no longer part of this
|
// Ensure messages that are no longer part of this
|
||||||
// narrow are deleted and messages that are now part
|
// narrow are deleted and messages that are now part
|
||||||
|
|||||||
@@ -69,12 +69,10 @@ exports.get_messages_in_topic = function (stream_id, topic) {
|
|||||||
exports.get_max_message_id_in_stream = function (stream_id) {
|
exports.get_max_message_id_in_stream = function (stream_id) {
|
||||||
let max_message_id = 0;
|
let max_message_id = 0;
|
||||||
for (const msg of message_list.all.all_messages()) {
|
for (const msg of message_list.all.all_messages()) {
|
||||||
if (msg.type === "stream" && msg.stream_id === stream_id) {
|
if (msg.type === "stream" && msg.stream_id === stream_id && msg.id > max_message_id) {
|
||||||
if (msg.id > max_message_id) {
|
|
||||||
max_message_id = msg.id;
|
max_message_id = msg.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return max_message_id;
|
return max_message_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,9 @@ const get_step = function ($process) {
|
|||||||
function should_show_notifications(ls) {
|
function should_show_notifications(ls) {
|
||||||
// if the user said to never show banner on this computer again, it will
|
// if the user said to never show banner on this computer again, it will
|
||||||
// be stored as `true` so we want to negate that.
|
// be stored as `true` so we want to negate that.
|
||||||
if (localstorage.supported()) {
|
if (localstorage.supported() && ls.get("dontAskForNotifications") === true) {
|
||||||
if (ls.get("dontAskForNotifications") === true) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// notifications *basically* don't work on any mobile platforms, so don't
|
// notifications *basically* don't work on any mobile platforms, so don't
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
$(() => {
|
$(() => {
|
||||||
// This code will be executed when the user visits /login and
|
// This code will be executed when the user visits /login and
|
||||||
// dev_login.html is rendered.
|
// dev_login.html is rendered.
|
||||||
if ($("[data-page-id='dev-login']").length > 0) {
|
if ($("[data-page-id='dev-login']").length > 0 && window.location.hash.slice(0, 1) === "#") {
|
||||||
if (window.location.hash.slice(0, 1) === "#") {
|
|
||||||
/* We append the location.hash to the input field with name next so that URL can be
|
/* We append the location.hash to the input field with name next so that URL can be
|
||||||
preserved after user is logged in. See this:
|
preserved after user is logged in. See this:
|
||||||
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
|
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
|
||||||
@@ -13,5 +12,4 @@ $(() => {
|
|||||||
$(this).attr("value", new_value);
|
$(this).attr("value", new_value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,16 +95,16 @@ $(() => {
|
|||||||
|
|
||||||
// Code in this block will be executed when the user visits /register
|
// Code in this block will be executed when the user visits /register
|
||||||
// i.e. accounts_home.html is rendered.
|
// i.e. accounts_home.html is rendered.
|
||||||
if ($("[data-page-id='accounts-home']").length > 0) {
|
if (
|
||||||
if (window.location.hash.slice(0, 1) === "#") {
|
$("[data-page-id='accounts-home']").length > 0 &&
|
||||||
|
window.location.hash.slice(0, 1) === "#"
|
||||||
|
) {
|
||||||
document.email_form.action += window.location.hash;
|
document.email_form.action += window.location.hash;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Code in this block will be executed when the user is at login page
|
// Code in this block will be executed when the user is at login page
|
||||||
// i.e. login.html is rendered.
|
// i.e. login.html is rendered.
|
||||||
if ($("[data-page-id='login-page']").length > 0) {
|
if ($("[data-page-id='login-page']").length > 0 && window.location.hash.slice(0, 1) === "#") {
|
||||||
if (window.location.hash.slice(0, 1) === "#") {
|
|
||||||
/* We append the location.hash to the formaction so that URL can be
|
/* We append the location.hash to the formaction so that URL can be
|
||||||
preserved after user is logged in. See this:
|
preserved after user is logged in. See this:
|
||||||
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
|
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
|
||||||
@@ -112,7 +112,6 @@ $(() => {
|
|||||||
$("#login_form").attr("action", email_formaction + "/" + window.location.hash);
|
$("#login_form").attr("action", email_formaction + "/" + window.location.hash);
|
||||||
$(".social_login_form input[name='next']").attr("value", "/" + window.location.hash);
|
$(".social_login_form input[name='next']").attr("value", "/" + window.location.hash);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$("#send_confirm").validate({
|
$("#send_confirm").validate({
|
||||||
errorElement: "div",
|
errorElement: "div",
|
||||||
|
|||||||
@@ -124,18 +124,14 @@ exports.update_info_from_event = function (user_id, info, server_timestamp) {
|
|||||||
raw.server_timestamp = server_timestamp;
|
raw.server_timestamp = server_timestamp;
|
||||||
|
|
||||||
for (const rec of Object.values(info)) {
|
for (const rec of Object.values(info)) {
|
||||||
if (rec.status === "active") {
|
if (rec.status === "active" && rec.timestamp > (raw.active_timestamp || 0)) {
|
||||||
if (rec.timestamp > (raw.active_timestamp || 0)) {
|
|
||||||
raw.active_timestamp = rec.timestamp;
|
raw.active_timestamp = rec.timestamp;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (rec.status === "idle") {
|
if (rec.status === "idle" && rec.timestamp > (raw.idle_timestamp || 0)) {
|
||||||
if (rec.timestamp > (raw.idle_timestamp || 0)) {
|
|
||||||
raw.idle_timestamp = rec.timestamp;
|
raw.idle_timestamp = rec.timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
raw_info.set(user_id, raw);
|
raw_info.set(user_id, raw);
|
||||||
|
|
||||||
|
|||||||
@@ -114,12 +114,11 @@ exports.get_direction = function (str) {
|
|||||||
// Extracting high and low surrogates and putting them together.
|
// 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.
|
// See https://en.wikipedia.org/wiki/UTF-16#Description or section 3 of https://tools.ietf.org/html/rfc2781.
|
||||||
let ch = str.charCodeAt(i);
|
let ch = str.charCodeAt(i);
|
||||||
if (ch >= 0xd800 && ch < 0xe000) {
|
if (ch >= 0xd800 && ch < 0xdc00) {
|
||||||
// 0xd800 <= ch < 0xe000
|
// 0xd800 <= ch < 0xdc00
|
||||||
// ch is inside surrogate range.
|
// ch is inside high surrogate range.
|
||||||
// If it made a surrogate pair with the next character, put them together.
|
// If it made a surrogate pair with the next character, put them together.
|
||||||
// Otherwise, ignore the encoding error and leave it as it is.
|
// 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;
|
const ch2 = i + 1 < str.length ? str.charCodeAt(i + 1) : 0;
|
||||||
if (ch2 >= 0xdc00 && ch2 < 0xe000) {
|
if (ch2 >= 0xdc00 && ch2 < 0xe000) {
|
||||||
// 0xdc00 <= ch2 < 0xe000
|
// 0xdc00 <= ch2 < 0xe000
|
||||||
@@ -130,7 +129,6 @@ exports.get_direction = function (str) {
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const bidi_class = get_bidi_class(ch);
|
const bidi_class = get_bidi_class(ch);
|
||||||
if (bidi_class === "I") {
|
if (bidi_class === "I") {
|
||||||
@@ -145,12 +143,10 @@ exports.get_direction = function (str) {
|
|||||||
if (isolations === 0) {
|
if (isolations === 0) {
|
||||||
return "rtl";
|
return "rtl";
|
||||||
}
|
}
|
||||||
} else if (bidi_class === "L") {
|
} else if (bidi_class === "L" && isolations === 0) {
|
||||||
if (isolations === 0) {
|
|
||||||
return "ltr";
|
return "ltr";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return "ltr";
|
return "ltr";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -702,17 +702,18 @@ 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
|
// This is unique to the legacy search system. With pills
|
||||||
// it is difficult to "suggest" a subset of operators,
|
// it is difficult to "suggest" a subset of operators,
|
||||||
// and there's a more natural mechanism under that paradigm,
|
// and there's a more natural mechanism under that paradigm,
|
||||||
// where the user just deletes one or more pills. So you
|
// where the user just deletes one or more pills. So you
|
||||||
// won't see this is in the new code.
|
// won't see this is in the new code.
|
||||||
if (attacher.result.length < max_items) {
|
attacher.result.length < max_items
|
||||||
|
) {
|
||||||
const subset_suggestions = get_operator_subset_suggestions(search_operators);
|
const subset_suggestions = get_operator_subset_suggestions(search_operators);
|
||||||
attacher.concat(subset_suggestions);
|
attacher.concat(subset_suggestions);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return attacher.result.slice(0, max_items);
|
return attacher.result.slice(0, max_items);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -97,12 +97,10 @@ exports.render_bots = function () {
|
|||||||
user_owns_an_active_bot = user_owns_an_active_bot || elem.is_active;
|
user_owns_an_active_bot = user_owns_an_active_bot || elem.is_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exports.can_create_new_bots()) {
|
if (exports.can_create_new_bots() && !user_owns_an_active_bot) {
|
||||||
if (!user_owns_an_active_bot) {
|
|
||||||
focus_tab.add_a_new_bot_tab();
|
focus_tab.add_a_new_bot_tab();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($("#bots_lists_navbar .add-a-new-bot-tab").hasClass("active")) {
|
if ($("#bots_lists_navbar .add-a-new-bot-tab").hasClass("active")) {
|
||||||
$("#add-a-new-bot-form").show();
|
$("#add-a-new-bot-form").show();
|
||||||
|
|||||||
@@ -154,13 +154,11 @@ class PerStreamHistory {
|
|||||||
|
|
||||||
const existing = this.topics.get(topic_name);
|
const existing = this.topics.get(topic_name);
|
||||||
|
|
||||||
if (existing) {
|
if (existing && !existing.historical) {
|
||||||
if (!existing.historical) {
|
|
||||||
// Trust out local data more, since it
|
// Trust out local data more, since it
|
||||||
// maintains counts.
|
// maintains counts.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, we are either finding out about
|
// If we get here, we are either finding out about
|
||||||
// the topic for the first time, or we are getting
|
// the topic for the first time, or we are getting
|
||||||
|
|||||||
@@ -343,12 +343,10 @@ exports.update_settings_for_unsubscribed = function (sub) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function triage_stream(query, sub) {
|
function triage_stream(query, sub) {
|
||||||
if (query.subscribed_only) {
|
if (query.subscribed_only && !sub.subscribed) {
|
||||||
// reject non-subscribed streams
|
// reject non-subscribed streams
|
||||||
if (!sub.subscribed) {
|
|
||||||
return "rejected";
|
return "rejected";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const search_terms = search_util.get_search_terms(query.input);
|
const search_terms = search_util.get_search_terms(query.input);
|
||||||
|
|
||||||
|
|||||||
@@ -95,14 +95,16 @@ exports.last_seen_status_from_date = function (last_active_date, current_date) {
|
|||||||
|
|
||||||
if (days < 90) {
|
if (days < 90) {
|
||||||
return i18n.t("__days__ days ago", {days});
|
return i18n.t("__days__ days ago", {days});
|
||||||
} else if (days > 90 && days < 365) {
|
} else if (
|
||||||
if (current_date.getFullYear() === last_active_date.getFullYear()) {
|
days > 90 &&
|
||||||
|
days < 365 &&
|
||||||
|
current_date.getFullYear() === last_active_date.getFullYear()
|
||||||
|
) {
|
||||||
// Online more than 90 days ago, in the same year
|
// Online more than 90 days ago, in the same year
|
||||||
return i18n.t("__last_active_date__", {
|
return i18n.t("__last_active_date__", {
|
||||||
last_active_date: last_active_date.toString("MMM\u00A0dd"),
|
last_active_date: last_active_date.toString("MMM\u00A0dd"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return i18n.t("__last_active_date__", {
|
return i18n.t("__last_active_date__", {
|
||||||
last_active_date: last_active_date.toString("MMM\u00A0dd,\u00A0yyyy"),
|
last_active_date: last_active_date.toString("MMM\u00A0dd,\u00A0yyyy"),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,11 +74,9 @@ exports.initialize_kitchen_sink_stuff = function () {
|
|||||||
if (message_viewport.at_top()) {
|
if (message_viewport.at_top()) {
|
||||||
navigate.up();
|
navigate.up();
|
||||||
}
|
}
|
||||||
} else if (delta > 0) {
|
} else if (delta > 0 && message_viewport.at_bottom()) {
|
||||||
if (message_viewport.at_bottom()) {
|
|
||||||
navigate.down();
|
navigate.down();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
message_viewport.set_last_movement_direction(delta);
|
message_viewport.set_last_movement_direction(delta);
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|||||||
Reference in New Issue
Block a user