mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +00:00
message_events: Fix live update of message edit history.
This commit adds code to live update the message edit history. Message edit history is fetched and rendered again if the edit history modal is open. This also adds 'data-message-id' attribute to 'message-history' when opening history modal element which is used for checking whether the history modal opened is of the message which is edited. Fixes #15051.
This commit is contained in:
@@ -7,6 +7,7 @@ zrequire('stream_data');
|
||||
zrequire('stream_topic_history');
|
||||
zrequire('unread');
|
||||
|
||||
set_global('$', global.make_zjquery());
|
||||
set_global('alert_words', {});
|
||||
set_global('condense', {});
|
||||
set_global('current_msg_list', {});
|
||||
|
||||
@@ -768,9 +768,7 @@ exports.edit_last_sent_message = function () {
|
||||
});
|
||||
};
|
||||
|
||||
exports.show_history = function (message) {
|
||||
$('#message-history').html('');
|
||||
$('#message-edit-history').modal("show");
|
||||
exports.fetch_and_render_message_history = function (message) {
|
||||
channel.get({
|
||||
url: "/json/messages/" + message.id + "/history",
|
||||
data: {message_id: JSON.stringify(message.id)},
|
||||
@@ -816,7 +814,7 @@ exports.show_history = function (message) {
|
||||
|
||||
content_edit_history.push(item);
|
||||
}
|
||||
|
||||
$('#message-history').attr('data-message-id', message.id);
|
||||
$('#message-history').html(render_message_edit_history({
|
||||
edited_messages: content_edit_history,
|
||||
}));
|
||||
@@ -828,6 +826,12 @@ exports.show_history = function (message) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.show_history = function (message) {
|
||||
$('#message-history').html('');
|
||||
$('#message-edit-history').modal("show");
|
||||
exports.fetch_and_render_message_history(message);
|
||||
};
|
||||
|
||||
function hide_delete_btn_show_spinner(deleting) {
|
||||
if (deleting) {
|
||||
$('do_delete_message_button').attr('disabled', 'disabled');
|
||||
|
||||
@@ -319,6 +319,12 @@ exports.update_messages = function update_messages(events) {
|
||||
recent_senders.process_topic_edit(...args);
|
||||
recent_topics.process_topic_edit(...args);
|
||||
}
|
||||
|
||||
// Rerender "Message edit history" if it was open to the edited message.
|
||||
if ($('#message-edit-history').hasClass('in') &&
|
||||
msg.id === parseInt($('#message-history').attr('data-message-id'), 10)) {
|
||||
message_edit.fetch_and_render_message_history(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// If a topic was edited, we re-render the whole view to get any
|
||||
|
||||
Reference in New Issue
Block a user