diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-05-08 22:00:00 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-05-08 22:24:33 +0200 |
commit | 0db3a413b3255885e21821830943476c83b091b0 (patch) | |
tree | 78d179fb2d9eb76a5edd1f84bb876e59d1a51332 /apps/comments/js | |
parent | 002018d8ada703db05302260e192aa6d183a8f32 (diff) | |
download | nextcloud-server-0db3a413b3255885e21821830943476c83b091b0.tar.gz nextcloud-server-0db3a413b3255885e21821830943476c83b091b0.zip |
Fix mentioned user not clickable after posting or editing a comment
The contactsMenu plugin was called on avatar elements from
_postRenderItem, which is called when a new comment is added to the
collection. Due to this contactsMenu was not called when messages were
edited; when a new comment is posted _postRenderItem is called, but at
that time the "mentions" attribute is not filled yet, so "@username" is
not replaced by avatars in the message and thus contactsMenu has no
avatars to be called on.
Calling contactsMenu was moved to a new method, _postRenderMessage,
which is called from _postRenderItem and from the success callback when
fetching the model in _onSubmitSuccess (which replaces "@username" by
avatars in the message after posting or editing a comment).
Fixes #4555
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/comments/js')
-rw-r--r-- | apps/comments/js/commentstabview.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index ace0862ad2e..3a20604326b 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -239,8 +239,12 @@ username, 0, $el.find('.authorRow')); } - var message = $el.find('.message'); - message.find('.avatar').each(function() { + var $message = $el.find('.message'); + this._postRenderMessage($message); + }, + + _postRenderMessage: function($el) { + $el.find('.avatar').each(function() { var avatar = $(this); var strong = $(this).next(); var appendTo = $(this).parent(); @@ -419,10 +423,13 @@ $textArea.val('').prop('disabled', false); } - $target.find('.message') + var $message = $target.find('.message'); + $message .html(self._formatMessage(model.get('message'), model.get('mentions'))) .find('.avatar') .each(function () { $(this).avatar(); }); + + self._postRenderMessage($message); }, error: function () { self._onSubmitError($form, commentId); |