summaryrefslogtreecommitdiffstats
path: root/apps/comments
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-02-13 17:49:05 -0600
committerMorris Jobke <hey@morrisjobke.de>2017-02-13 17:53:33 -0600
commit200a28255e058843465c63080d917170de293ee6 (patch)
tree86c8f04fc95b22e8f2e973e16f026ae1d2552ec3 /apps/comments
parent88047aaea732d77bf38730566842fc163c6ba3a1 (diff)
downloadnextcloud-server-200a28255e058843465c63080d917170de293ee6.tar.gz
nextcloud-server-200a28255e058843465c63080d917170de293ee6.zip
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 <hey@morrisjobke.de>
Diffstat (limited to 'apps/comments')
-rw-r--r--apps/comments/js/commentstabview.js34
-rw-r--r--apps/comments/tests/js/commentstabviewSpec.js17
2 files changed, 12 insertions, 39 deletions
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 =
'<div class="newCommentRow comment" data-id="{{id}}">' +
' <div class="authorRow">' +
- ' {{#if avatarEnabled}}' +
' <div class="avatar" data-username="{{actorId}}"></div>' +
- ' {{/if}}' +
' <div class="author">{{actorDisplayName}}</div>' +
'{{#if isEditMode}}' +
' <a href="#" class="action delete icon icon-delete has-tooltip" title="{{deleteTooltip}}"></a>' +
@@ -44,9 +42,7 @@
var COMMENT_TEMPLATE =
'<li class="comment{{#if isUnread}} unread{{/if}}{{#if isLong}} collapsed{{/if}}" data-id="{{id}}">' +
' <div class="authorRow">' +
- ' {{#if avatarEnabled}}' +
' <div class="avatar" {{#if actorId}}data-username="{{actorId}}"{{/if}}> </div>' +
- ' {{/if}}' +
' <div class="author">{{actorDisplayName}}</div>' +
'{{#if isUserAuthor}}' +
' <a href="#" class="action edit icon icon-rename has-tooltip" title="{{editTooltip}}"></a>' +
@@ -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 = '<div class="avatar" '
- + 'data-user="' + _.escape(mentions[i].mentionId) + '"'
- +' data-user-display-name="'
- + _.escape(mentions[i].mentionDisplayName) + '"></div>';
- }
+ var avatar = '<div class="avatar" '
+ + 'data-user="' + _.escape(mentions[i].mentionId) + '"'
+ +' data-user-display-name="'
+ + _.escape(mentions[i].mentionDisplayName) + '"></div>';
// 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();
});