diff --git a/static/js/loading.js b/static/js/loading.js index d2c1113f24..201ecb2c31 100644 --- a/static/js/loading.js +++ b/static/js/loading.js @@ -2,8 +2,7 @@ import $ from "jquery"; import render_loader from "../templates/loader.hbs"; -export function make_indicator(outer_container, opts) { - opts = opts || {}; +export function make_indicator(outer_container, {abs_positioned = false, text} = {}) { let container = outer_container; // TODO: We set white-space to 'nowrap' because under some @@ -15,7 +14,7 @@ export function make_indicator(outer_container, opts) { container.empty(); - if (opts.abs_positioned !== undefined && opts.abs_positioned) { + if (abs_positioned) { // Create some additional containers to facilitate absolutely // positioned spinners. const container_id = container.attr("id"); @@ -32,12 +31,12 @@ export function make_indicator(outer_container, opts) { container.append(spinner_elem); let text_width = 0; - if (opts.text !== undefined && opts.text !== "") { + if (text !== undefined) { const text_elem = $(''); - text_elem.text(opts.text); + text_elem.text(text); container.append(text_elem); // See note, below - if (!(opts.abs_positioned !== undefined && opts.abs_positioned)) { + if (!abs_positioned) { text_width = 20 + text_elem.width(); } } diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js index c2b539b953..f8694f5736 100644 --- a/static/js/message_viewport.js +++ b/static/js/message_viewport.js @@ -342,9 +342,7 @@ export function user_initiated_animate_scroll(scroll_amount) { }); } -export function recenter_view(message, opts) { - opts = opts || {}; - +export function recenter_view(message, {from_scroll = false, force_center = false} = {}) { // BarnOwl-style recentering: if the pointer is too high, move it to // the 1/2 marks. If the pointer is too low, move it to the 1/7 mark. // See keep_pointer_in_view() for related logic to keep the pointer onscreen. @@ -361,7 +359,7 @@ export function recenter_view(message, opts) { const is_above = message_top < top_threshold; const is_below = message_bottom > bottom_threshold; - if (opts.from_scroll) { + if (from_scroll) { // If the message you're trying to center on is already in view AND // you're already trying to move in the direction of that message, // don't try to recenter. This avoids disorienting jumps when the @@ -375,7 +373,7 @@ export function recenter_view(message, opts) { } } - if (is_above || opts.force_center) { + if (is_above || force_center) { set_message_position(message_top, message_height, viewport_info, 1 / 2); } else if (is_below) { set_message_position(message_top, message_height, viewport_info, 1 / 7); diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js index 6e468d517c..84aa686f1b 100644 --- a/static/js/unread_ops.js +++ b/static/js/unread_ops.js @@ -75,8 +75,7 @@ export function process_read_messages_event(message_ids) { // Takes a list of messages and marks them as read. // Skips any messages that are already marked as read. -export function notify_server_messages_read(messages, options) { - options = options || {}; +export function notify_server_messages_read(messages, options = {}) { messages = unread.get_unread_messages(messages); if (messages.length === 0) { return;