From 200a28255e058843465c63080d917170de293ee6 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 13 Feb 2017 17:49:05 -0600 Subject: Always enable avatars * we introduced this setting in the begining because our avatar support caused some performance issues, but we fixed them and should only provide one way how Nextcloud looks Signed-off-by: Morris Jobke --- apps/comments/js/commentstabview.js | 34 +++++++-------------------- apps/comments/tests/js/commentstabviewSpec.js | 17 +++----------- 2 files changed, 12 insertions(+), 39 deletions(-) (limited to 'apps/comments') diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 8387e527f4a..f60968616a2 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -23,9 +23,7 @@ var EDIT_COMMENT_TEMPLATE = '
' + '
' + - ' {{#if avatarEnabled}}' + '
' + - ' {{/if}}' + '
{{actorDisplayName}}
' + '{{#if isEditMode}}' + ' ' + @@ -44,9 +42,7 @@ var COMMENT_TEMPLATE = '
  • ' + '
    ' + - ' {{#if avatarEnabled}}' + '
    ' + - ' {{/if}}' + '
    {{actorDisplayName}}
    ' + '{{#if isUserAuthor}}' + ' ' + @@ -85,8 +81,6 @@ this.collection.on('sync', this._onEndRequest, this); this.collection.on('add', this._onAddModel, this); - this._avatarsEnabled = !!OC.config.enable_avatars; - this._commentMaxThreshold = this._commentMaxLength * 0.9; // TODO: error handling @@ -99,7 +93,6 @@ } var currentUser = OC.getCurrentUser(); return this._template(_.extend({ - avatarEnabled: this._avatarsEnabled, actorId: currentUser.uid, actorDisplayName: currentUser.displayName }, params)); @@ -111,7 +104,6 @@ } var currentUser = OC.getCurrentUser(); return this._editCommentTemplate(_.extend({ - avatarEnabled: this._avatarsEnabled, actorId: currentUser.uid, actorDisplayName: currentUser.displayName, newMessagePlaceholder: t('comments', 'New comment …'), @@ -127,7 +119,6 @@ } params = _.extend({ - avatarEnabled: this._avatarsEnabled, editTooltip: t('comments', 'Edit comment'), isUserAuthor: OC.getCurrentUser().uid === params.actorId, isLong: this._isLong(params.message) @@ -169,9 +160,7 @@ this.$el.find('.comments').before(this.editCommentTemplate({})); this.$el.find('.has-tooltip').tooltip(); this.$container = this.$el.find('ul.comments'); - if (this._avatarsEnabled) { - this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 32); - } + this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 32); this.delegateEvents(); this.$el.find('.message').on('keydown input change', this._onTypeComment); @@ -239,12 +228,10 @@ _postRenderItem: function($el) { $el.find('.has-tooltip').tooltip(); - if(this._avatarsEnabled) { - $el.find('.avatar').each(function() { - var $this = $(this); - $this.avatar($this.attr('data-username'), 32); - }); - } + $el.find('.avatar').each(function() { + var $this = $(this); + $this.avatar($this.attr('data-username'), 32); + }); }, /** @@ -257,13 +244,10 @@ for(var i in mentions) { var mention = '@' + mentions[i].mentionId; - var avatar = ''; - if(this._avatarsEnabled) { - avatar = '
    '; - } + var avatar = '
    '; // escape possible regex characters in the name mention = mention.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js index 9e4bf4f0533..0bbfaa1f295 100644 --- a/apps/comments/tests/js/commentstabviewSpec.js +++ b/apps/comments/tests/js/commentstabviewSpec.js @@ -43,7 +43,6 @@ describe('OCA.Comments.CommentsTabView tests', function() { clock = sinon.useFakeTimers(Date.UTC(2016, 1, 3, 10, 5, 9)); fetchStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'fetchNext'); view = new OCA.Comments.CommentsTabView(); - view._avatarsEnabled = false; fileInfoModel = new OCA.Files.FileInfoModel({ id: 5, name: 'One.txt', @@ -146,7 +145,6 @@ describe('OCA.Comments.CommentsTabView tests', function() { }); it('renders mentioned user id to avatar and displayname', function() { - view._avatarsEnabled = true; view.collection.set(testComments); var $comment = view.$el.find('.comment[data-id=3] .message'); @@ -158,18 +156,6 @@ describe('OCA.Comments.CommentsTabView tests', function() { expect($comment.find('strong:last-child').text()).toEqual('Lord Banquo'); }); - it('renders mentioned user id to displayname, avatars disabled', function() { - view.collection.set(testComments); - - var $comment = view.$el.find('.comment[data-id=3] .message'); - expect($comment.length).toEqual(1); - expect($comment.find('.avatar[data-user=macbeth]').length).toEqual(0); - expect($comment.find('strong:first-child').text()).toEqual('Thane of Cawdor'); - - expect($comment.find('.avatar[data-user=banquo]').length).toEqual(0); - expect($comment.find('strong:last-child').text()).toEqual('Lord Banquo'); - }); - }); describe('more comments', function() { var hasMoreResultsStub; @@ -316,11 +302,13 @@ describe('OCA.Comments.CommentsTabView tests', function() { describe('editing comments', function() { var saveStub; var fetchStub; + var avatarStub; var currentUserStub; beforeEach(function() { saveStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'save'); fetchStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'fetch'); + avatarStub = sinon.stub($.fn, 'avatar'); currentUserStub = sinon.stub(OC, 'getCurrentUser'); currentUserStub.returns({ uid: 'testuser', @@ -348,6 +336,7 @@ describe('OCA.Comments.CommentsTabView tests', function() { afterEach(function() { saveStub.restore(); fetchStub.restore(); + avatarStub.restore(); currentUserStub.restore(); }); -- cgit v1.2.3