mirror of https://github.com/zulip/zulip.git
message_edit: Fix display of repeated stream moves.
The recent commits to display the previous and new streams for a moved message did not correctly handle messages moved multiple times. To do this, we need to do a somewhat awkward loop, at least until we modify the API to do this loop for us.
This commit is contained in:
parent
71ce154a02
commit
b7a07a753f
|
@ -24,6 +24,7 @@ export function fetch_and_render_message_history(message) {
|
|||
success(data) {
|
||||
const content_edit_history = [];
|
||||
let prev_time = null;
|
||||
let prev_stream_item = null;
|
||||
|
||||
for (const [index, msg] of data.message_history.entries()) {
|
||||
// Format times and dates nicely for display
|
||||
|
@ -60,7 +61,12 @@ export function fetch_and_render_message_history(message) {
|
|||
} else {
|
||||
item.prev_stream = stream_data.maybe_get_stream_name(msg.prev_stream);
|
||||
}
|
||||
item.new_stream = stream_data.maybe_get_stream_name(message.stream_id);
|
||||
if (prev_stream_item !== null) {
|
||||
prev_stream_item.new_stream = stream_data.maybe_get_stream_name(
|
||||
msg.prev_stream,
|
||||
);
|
||||
}
|
||||
prev_stream_item = item;
|
||||
} else if (msg.prev_topic) {
|
||||
item.posted_or_edited = $t({defaultMessage: "Topic edited by"});
|
||||
item.topic_edited = true;
|
||||
|
@ -75,7 +81,12 @@ export function fetch_and_render_message_history(message) {
|
|||
} else {
|
||||
item.prev_stream = stream_data.maybe_get_stream_name(msg.prev_stream);
|
||||
}
|
||||
item.new_stream = stream_data.maybe_get_stream_name(message.stream_id);
|
||||
if (prev_stream_item !== null) {
|
||||
prev_stream_item.new_stream = stream_data.maybe_get_stream_name(
|
||||
msg.prev_stream,
|
||||
);
|
||||
}
|
||||
prev_stream_item = item;
|
||||
} else {
|
||||
// just a content edit
|
||||
item.posted_or_edited = $t({defaultMessage: "Edited by"});
|
||||
|
@ -83,9 +94,11 @@ export function fetch_and_render_message_history(message) {
|
|||
}
|
||||
|
||||
content_edit_history.push(item);
|
||||
|
||||
prev_time = time;
|
||||
}
|
||||
if (prev_stream_item !== null) {
|
||||
prev_stream_item.new_stream = stream_data.maybe_get_stream_name(message.stream_id);
|
||||
}
|
||||
$("#message-history").attr("data-message-id", message.id);
|
||||
$("#message-history").html(
|
||||
render_message_edit_history({
|
||||
|
|
Loading…
Reference in New Issue