mirror of https://github.com/zulip/zulip.git
Get rid of the selected_message_class global
Instead we infer this from narrow.active(), with the ability to override during the narrowing procedure. (imported from commit fab9c6861f19aedf0ee8af094c1ef4e8a0a73d80)
This commit is contained in:
parent
6e63ac926e
commit
582cb799dd
|
@ -38,7 +38,7 @@ var globals =
|
|||
+ ' update_autocomplete autocomplete_needs_update'
|
||||
|
||||
// zephyr.js
|
||||
+ ' message_array message_dict selected_message_class'
|
||||
+ ' message_array message_dict'
|
||||
+ ' clear_table add_to_table subject_dict'
|
||||
+ ' keep_pointer_in_view move_pointer_at_page_top_and_bottom'
|
||||
+ ' respond_to_message'
|
||||
|
|
|
@ -32,6 +32,8 @@ exports.narrowing_type = function () {
|
|||
};
|
||||
|
||||
function do_narrow(icon, description, filter_function) {
|
||||
var was_narrowed = exports.active();
|
||||
|
||||
narrowed = filter_function;
|
||||
|
||||
// Your pointer isn't changed when narrowed.
|
||||
|
@ -58,8 +60,8 @@ function do_narrow(icon, description, filter_function) {
|
|||
// Indicate both which message is persistently selected and which
|
||||
// is temporarily selected
|
||||
select_message_by_id(selected_message_id,
|
||||
{then_scroll: false, update_server: false});
|
||||
selected_message_class = "narrowed_selected_message";
|
||||
{then_scroll: false, update_server: false,
|
||||
for_narrow: was_narrowed});
|
||||
select_message_by_id(target_id,
|
||||
{then_scroll: true, update_server: false});
|
||||
|
||||
|
@ -154,7 +156,6 @@ exports.show_all_messages = function () {
|
|||
$("#searchbox").removeClass('narrowed_view');
|
||||
$("#show_all_messages").attr("disabled", "disabled");
|
||||
$("#currently_narrowed_to").html("");
|
||||
selected_message_class = "selected_message";
|
||||
// Includes scrolling.
|
||||
select_message_by_id(persistent_message_id, {then_scroll: true});
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ var message_dict = {};
|
|||
var subject_dict = {};
|
||||
var people_hash = {};
|
||||
|
||||
var selected_message_class = 'selected_message';
|
||||
var viewport = $(window);
|
||||
var reloading_app = false;
|
||||
|
||||
|
@ -188,9 +187,14 @@ function send_pointer_update() {
|
|||
$(setTimeout(send_pointer_update, 1000));
|
||||
|
||||
function update_selected_message(message, opts) {
|
||||
opts = $.extend({}, {update_server: true}, opts);
|
||||
$('.' + selected_message_class).removeClass(selected_message_class);
|
||||
message.addClass(selected_message_class);
|
||||
opts = $.extend({}, {
|
||||
update_server: true,
|
||||
for_narrow: narrow.active()
|
||||
}, opts);
|
||||
|
||||
var cls = opts.for_narrow ? 'narrowed_selected_message' : 'selected_message';
|
||||
$('.' + cls).removeClass(cls);
|
||||
message.addClass(cls);
|
||||
|
||||
var new_selected_id = rows.id(message);
|
||||
if (opts.update_server && !narrow.active()
|
||||
|
|
Loading…
Reference in New Issue