Refresh page when message with /me is edited.

Fixes: #163.

Thanks to Catherine Nguyen (@cnguye11) for her work on this.
This commit is contained in:
Tomasz Kolek 2016-05-31 14:24:58 +02:00 committed by Tim Abbott
parent 3ed78eb746
commit 0820ab591a
2 changed files with 37 additions and 9 deletions

View File

@ -47,6 +47,30 @@ casper.waitForSelector(".message_edit_notice", function () {
casper.test.assertSelectorHasText(".last_message .message_content", "test edited");
});
common.then_send_message('stream', {
stream: 'Verona',
subject: 'edits',
content: '/me test editing one line with me'
});
casper.waitForText("test editing one line with me");
wait_for_message_actually_sent();
then_edit_last_message();
casper.then(function () {
casper.evaluate(function () {
var msg = $('#zhome .message_row:last');
msg.find('.message_edit_topic').val("edited");
msg.find('.message_edit_content').val("/me test edited one line with me");
msg.find('.message_edit_save').click();
});
});
casper.waitForSelector(".message_edit_notice", function () {
casper.test.assertSelectorHasText(".last_message .sender-status", "test edited one line with me");
});
common.then_send_message('private', {
recipient: "cordelia@zulip.com",
content: "test editing pm"

View File

@ -196,15 +196,7 @@ MessageListView.prototype = {
message_container.contains_mention = notifications.speaking_at_me(message_container.msg);
message_container.msg.unread = unread.message_unread(message_container.msg);
if (message_container.msg.is_me_message) {
// Slice the '<p>/me ' off the front, and '</p>' off the end
message_container.status_message = message_container.msg.content.slice(4 + 3, -4);
message_container.include_sender = true;
}
else {
message_container.status_message = false;
}
self._maybe_format_me_message(message_container);
prev = message_container;
});
@ -752,6 +744,7 @@ MessageListView.prototype = {
// Re-render just this one message
this._add_msg_timestring(message_container);
this._maybe_format_me_message(message_container);
var msg_to_render = _.extend(message_container, {table_name: this.table_name});
var rendered_msg = $(templates.render('single_message', msg_to_render));
@ -893,6 +886,17 @@ MessageListView.prototype = {
this.message_containers[new_id] = message_container;
}
},
_maybe_format_me_message: function MessageListView__maybe_format_me_message(message_container) {
if (message_container.msg.is_me_message) {
// Slice the '<p>/me ' off the front, and '</p>' off the end
message_container.status_message = message_container.msg.content.slice(4 + 3, -4);
message_container.include_sender = true;
}
else {
message_container.status_message = false;
}
}
};