mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
Fix topic edits that are initiated from the FRB.
Grab the id of the selected row, whether it's a message, recipient bar, or FRB (imported from commit 93b9c282d4220ba9bb271733ded4d90d5c051c75)
This commit is contained in:
@@ -6,14 +6,14 @@ var currently_editing_messages = {};
|
||||
//returns true if the edit task should end.
|
||||
exports.save = function (row) {
|
||||
var msg_list = current_msg_list;
|
||||
var message_row;
|
||||
var message_id;
|
||||
|
||||
if (row.hasClass('recipient_row')) {
|
||||
message_row = rows.first_message_in_group(row);
|
||||
message_id = rows.id_for_recipient_row(row);
|
||||
} else {
|
||||
message_row = row;
|
||||
message_id = rows.id(row);
|
||||
}
|
||||
var message = current_msg_list.get(rows.id(message_row));
|
||||
var message = current_msg_list.get(message_id);
|
||||
var changed = false;
|
||||
|
||||
var new_content = row.find(".message_edit_content").val();
|
||||
@@ -162,7 +162,8 @@ exports.start_topic_edit = function (recipient_row) {
|
||||
var form = $(templates.render('topic_edit_form'));
|
||||
current_msg_list.show_edit_topic(recipient_row, form);
|
||||
form.keydown(handle_edit_keydown);
|
||||
var message = current_msg_list.get(rows.id(rows.first_message_in_group(recipient_row)));
|
||||
var msg_id = rows.id_for_recipient_row(recipient_row);
|
||||
var message = current_msg_list.get(msg_id);
|
||||
var topic = message.subject;
|
||||
if (topic === compose.empty_subject_placeholder()) {
|
||||
topic = '';
|
||||
|
||||
@@ -85,6 +85,20 @@ exports.recipient_from_group = function (message_group) {
|
||||
return message_store.get(exports.id($(message_group).children('.message_row').first().expectOne()));
|
||||
};
|
||||
|
||||
exports.id_for_recipient_row = function (recipient_row) {
|
||||
// A recipient row can be either a normal recipient row, or
|
||||
// the FRB, which is a fake recipient row. If it's a FRB, it has
|
||||
// a 'zid' property that stores the message id it is directly over
|
||||
var msg_row = exports.first_message_in_group(recipient_row);
|
||||
if (msg_row.length === 0) {
|
||||
// If we're narrowing from the FRB, take the msg id
|
||||
// directly from it
|
||||
return exports.id(recipient_row);
|
||||
} else {
|
||||
return exports.id(msg_row);
|
||||
}
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
}());
|
||||
|
||||
@@ -1101,16 +1101,7 @@ $(function () {
|
||||
|
||||
function get_row_id_for_narrowing(narrow_link_elem) {
|
||||
var group = rows.get_closest_group(narrow_link_elem);
|
||||
var msg_row = rows.first_message_in_group(group);
|
||||
var msg_id;
|
||||
|
||||
if (msg_row.length === 0) {
|
||||
// If we're narrowing from the FRB, take the msg id
|
||||
// directly from it
|
||||
msg_id = rows.id(group);
|
||||
} else {
|
||||
msg_id = rows.id(msg_row);
|
||||
}
|
||||
var msg_id = rows.id_for_recipient_row(group);
|
||||
|
||||
var nearest = current_msg_list.get(msg_id);
|
||||
var selected = current_msg_list.selected_message();
|
||||
|
||||
Reference in New Issue
Block a user