From 124f5d12a462a6909991c179a9b8a215b1d62811 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 20 Nov 2019 14:20:39 -0800 Subject: [PATCH] message_edit: Adjust API of edit_locally. This makes it more extensible for future use of locally echoing edits to fully sent messages. --- static/js/echo.js | 6 ++++-- static/js/message_edit.js | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/static/js/echo.js b/static/js/echo.js index 70fe093023..511c818378 100644 --- a/static/js/echo.js +++ b/static/js/echo.js @@ -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), diff --git a/static/js/message_edit.js b/static/js/message_edit.js index b4e09567c1..9f72f887e4 100644 --- a/static/js/message_edit.js +++ b/static/js/message_edit.js @@ -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);