mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
Make Enter on a summary row expand it.
(imported from commit 4ad44a96a225f6cfbb7d4f62ebf7c62298dd730b)
This commit is contained in:
@@ -261,6 +261,15 @@ function process_hotkey(e) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current_msg_list.summary_is_selected()) {
|
||||||
|
switch (event_name) {
|
||||||
|
case 'enter':
|
||||||
|
ui.expand_summary_row(current_msg_list.selected_row());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Shortcuts that operate on a message
|
// Shortcuts that operate on a message
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case 'message_actions':
|
case 'message_actions':
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ MessageList.prototype = {
|
|||||||
return rows.get(this._selected_id, this.table_name);
|
return rows.get(this._selected_id, this.table_name);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
summary_is_selected: function () {
|
||||||
|
return this._is_summarized_message(this.selected_message());
|
||||||
|
},
|
||||||
|
|
||||||
closest_id: function MessageList_closest_id(id) {
|
closest_id: function MessageList_closest_id(id) {
|
||||||
var items = this._items;
|
var items = this._items;
|
||||||
|
|
||||||
|
|||||||
@@ -700,6 +700,33 @@ exports.collapse = function (row) {
|
|||||||
show_more_link(row);
|
show_more_link(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.expand_summary_row = function (row) {
|
||||||
|
var message_ids = row.attr('data-messages').split(' ');
|
||||||
|
var messages = _.map(message_ids, function (id) {
|
||||||
|
return all_msg_list.get(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
function remove_flag(flag) {
|
||||||
|
_.each(messages, function (msg){
|
||||||
|
msg.flags = _.without(msg.flags, flag);
|
||||||
|
});
|
||||||
|
update_message_flag(messages, flag, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_flag('summarize_in_stream');
|
||||||
|
if (!narrow.active()) {
|
||||||
|
remove_flag('summarize_in_home');
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Avoid a full re-render
|
||||||
|
home_msg_list.rerender();
|
||||||
|
if (current_msg_list !== home_msg_list) {
|
||||||
|
current_msg_list.rerender();
|
||||||
|
}
|
||||||
|
|
||||||
|
current_msg_list.select_id(message_ids[0]);
|
||||||
|
};
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
// NB: This just binds to current elements, and won't bind to elements
|
// NB: This just binds to current elements, and won't bind to elements
|
||||||
// created after ready() is called.
|
// created after ready() is called.
|
||||||
@@ -952,30 +979,7 @@ $(function () {
|
|||||||
|
|
||||||
if (feature_flags.summarize_read_while_narrowed) {
|
if (feature_flags.summarize_read_while_narrowed) {
|
||||||
$("#main_div").on("click", ".summary_row", function (e) {
|
$("#main_div").on("click", ".summary_row", function (e) {
|
||||||
var target = $(e.target).closest('.summary_row');
|
exports.expand_summary_row($(e.target).closest('.summary_row'));
|
||||||
var message_ids = target.attr('data-messages').split(' ');
|
|
||||||
var messages = _.map(message_ids, function (id) {
|
|
||||||
return all_msg_list.get(id);
|
|
||||||
});
|
|
||||||
|
|
||||||
function remove_flag(flag) {
|
|
||||||
_.each(messages, function (msg){
|
|
||||||
msg.flags = _.without(msg.flags, flag);
|
|
||||||
});
|
|
||||||
update_message_flag(messages, flag, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_flag('summarize_in_stream');
|
|
||||||
if (!narrow.active()) {
|
|
||||||
remove_flag('summarize_in_home');
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Avoid a full re-render
|
|
||||||
home_msg_list.rerender();
|
|
||||||
if (current_msg_list !== home_msg_list) {
|
|
||||||
current_msg_list.rerender();
|
|
||||||
}
|
|
||||||
|
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user