message_edit: Adjust API of edit_locally.

This makes it more extensible for future use of locally echoing edits
to fully sent messages.
This commit is contained in:
Tim Abbott
2019-11-20 14:20:39 -08:00
parent 19234f8705
commit 124f5d12a4
2 changed files with 8 additions and 3 deletions

View File

@@ -134,10 +134,12 @@ exports.try_deliver_locally = function try_deliver_locally(message_request) {
return insert_local_message(message_request, next_local_id);
};
exports.edit_locally = function edit_locally(message, raw_content, new_topic) {
exports.edit_locally = function edit_locally(message, request) {
const raw_content = request.raw_content;
const message_content_edited = raw_content !== undefined && message.raw_content !== raw_content;
if (new_topic !== undefined) {
if (request.new_topic !== undefined) {
const new_topic = request.new_topic;
topic_data.remove_message({
stream_id: message.stream_id,
topic_name: util.get_message_topic(message),

View File

@@ -152,7 +152,10 @@ exports.save = function (row, from_topic_edited_only) {
// just results in the in-memory message being changed
if (message.locally_echoed) {
if (new_content !== message.raw_content || topic_changed) {
echo.edit_locally(message, new_content, topic_changed ? new_topic : undefined);
echo.edit_locally(message, {
raw_content: new_content,
new_topic: new_topic,
});
row = current_msg_list.get_row(message_id);
}
exports.end(row);