summaryrefslogtreecommitdiffstats
path: root/apps/comments/js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-10-23 15:37:36 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-10-23 15:37:36 +0200
commiteb8f1247fea28ff503a6bd330fd7be3fe0270662 (patch)
treebcf2553b3447de150ccf3ee383f54aff4b50f577 /apps/comments/js
parentde8a475b0b16f10c1586cc5c67737ad1791ce6a3 (diff)
downloadnextcloud-server-eb8f1247fea28ff503a6bd330fd7be3fe0270662.tar.gz
nextcloud-server-eb8f1247fea28ff503a6bd330fd7be3fe0270662.zip
fix unstable comment order
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/comments/js')
-rw-r--r--apps/comments/js/commentstabview.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js
index a8966749cf1..b3e17653f59 100644
--- a/apps/comments/js/commentstabview.js
+++ b/apps/comments/js/commentstabview.js
@@ -270,23 +270,30 @@
* @private
*/
_onAddModel: function(model, collection, options) {
- var self = this;
+ // we need to render it immediately, to ensure that the right
+ // order of comments is kept on opening comments tab
+ var $comment = $(this.commentTemplate(this._formatItem(model)));
+ if (!_.isUndefined(options.at) && collection.length > 1) {
+ this.$container.find('li').eq(options.at).before($comment);
+ } else {
+ this.$container.append($comment);
+ }
+ this._postRenderItem($comment);
+ $('#commentsTabView').find('.newCommentForm div.message').text('').prop('disabled', false);
+
// we need to update the model, because it consists of client data
// only, but the server might add meta data, e.g. about mentions
+ var oldMentions = model.get('mentions');
+ var self = this;
model.fetch({
success: function (model) {
- var $el = $(self.commentTemplate(self._formatItem(model)));
- if (!_.isUndefined(options.at) && collection.length > 1) {
- self.$container.find('li').eq(options.at).before($el);
- } else {
- self.$container.append($el);
+ if(_.isEqual(oldMentions, model.get('mentions'))) {
+ // don't attempt to render if unnecessary, avoids flickering
+ return;
}
-
- self._postRenderItem($el);
- $('#commentsTabView').find('.newCommentForm div.message').text('').prop('disabled', false);
- },
- error: function () {
- self._onSubmitError($('#commentsTabView').find('.newCommentForm'), undefined);
+ var $updated = $(self.commentTemplate(self._formatItem(model)));
+ $comment.html($updated.html());
+ self._postRenderItem($comment);
}
})
@@ -312,7 +319,6 @@
// ignore noise – this is only set after editing a comment and hitting post
return;
}
-
var self = this;
// we need to update the model, because it consists of client data