[Comments] Fix sort

This commit is contained in:
Julia Radzhabova 2021-11-25 00:43:25 +03:00
parent d0f3011e6c
commit 5995a0045a
2 changed files with 22 additions and 18 deletions

View file

@ -697,14 +697,15 @@ define([
var end = true; var end = true;
for (var i = this.collection.length - 1; i >= 0; --i) { for (var i = this.collection.length - 1; i >= 0; --i) {
if (end) { var item = this.collection.at(i);
this.collection.at(i).set('last', true, {silent: true}); if (end && !item.get('hide')) {
item.set('last', true, {silent: true});
end = false;
} else { } else {
if (this.collection.at(i).get('last')) { if (item.get('last')) {
this.collection.at(i).set('last', false, {silent: true}); item.set('last', false, {silent: true});
} }
} }
end = false;
} }
this.view.render(); this.view.render();
this.view.update(); this.view.update();
@ -822,6 +823,7 @@ define([
comment.set('userid', data.asc_getUserId()); comment.set('userid', data.asc_getUserId());
comment.set('username', data.asc_getUserName()); comment.set('username', data.asc_getUserName());
comment.set('parsedName', AscCommon.UserInfoParser.getParsedName(data.asc_getUserName())); comment.set('parsedName', AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()));
comment.set('parsedGroups', AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName()));
comment.set('usercolor', (user) ? user.get('color') : null); comment.set('usercolor', (user) ? user.get('color') : null);
comment.set('resolved', data.asc_getSolved()); comment.set('resolved', data.asc_getSolved());
comment.set('quote', data.asc_getQuoteText()); comment.set('quote', data.asc_getQuoteText());
@ -832,7 +834,7 @@ define([
comment.set('removable', (t.mode.canDeleteComments || (data.asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName())); comment.set('removable', (t.mode.canDeleteComments || (data.asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName()));
comment.set('hide', !AscCommon.UserInfoParser.canViewComment(data.asc_getUserName())); comment.set('hide', !AscCommon.UserInfoParser.canViewComment(data.asc_getUserName()));
!comment.get('hide') && t.fillUserGroups(data.asc_getUserName()); !comment.get('hide') && t.fillUserGroups(comment.get('parsedGroups'));
replies = _.clone(comment.get('replys')); replies = _.clone(comment.get('replys'));
@ -1152,14 +1154,15 @@ define([
this.onUpdateFilter(this.filter, true); this.onUpdateFilter(this.filter, true);
for (i = this.collection.length - 1; i >= 0; --i) { for (i = this.collection.length - 1; i >= 0; --i) {
if (end) { var item = this.collection.at(i);
this.collection.at(i).set('last', true, {silent: true}); if (end && !item.get('hide')) {
item.set('last', true, {silent: true});
end = false;
} else { } else {
if (this.collection.at(i).get('last')) { if (item.get('last')) {
this.collection.at(i).set('last', false, {silent: true}); item.set('last', false, {silent: true});
} }
} }
end = false;
} }
this.view.render(); this.view.render();
@ -1310,6 +1313,7 @@ define([
userid : data.asc_getUserId(), userid : data.asc_getUserId(),
username : data.asc_getUserName(), username : data.asc_getUserName(),
parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()), parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()),
parsedGroups : AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName()),
usercolor : (user) ? user.get('color') : null, usercolor : (user) ? user.get('color') : null,
date : this.dateToLocaleTimeString(date), date : this.dateToLocaleTimeString(date),
quote : data.asc_getQuoteText(), quote : data.asc_getQuoteText(),
@ -1333,7 +1337,7 @@ define([
groupName : (groupname && groupname.length>1) ? groupname[1] : null groupName : (groupname && groupname.length>1) ? groupname[1] : null
}); });
if (comment) { if (comment) {
!comment.get('hide') && this.fillUserGroups(data.asc_getUserName()); !comment.get('hide') && this.fillUserGroups(comment.get('parsedGroups'));
var replies = this.readSDKReplies(data); var replies = this.readSDKReplies(data);
if (replies.length) { if (replies.length) {
comment.set('replys', replies); comment.set('replys', replies);
@ -1646,16 +1650,14 @@ define([
this.groupCollection = []; this.groupCollection = [];
}, },
fillUserGroups: function(username) { fillUserGroups: function(usergroups) {
if (!this.mode.canUseCommentPermissions) return; if (!this.mode.canUseCommentPermissions) return;
var usergroups = AscCommon.UserInfoParser.getParsedGroups(username), var viewgroups = AscCommon.UserInfoParser.getCommentPermissions('view');
viewgroups = AscCommon.UserInfoParser.getCommentPermissions('view');
if (usergroups && usergroups.length>0) { if (usergroups && usergroups.length>0) {
if (viewgroups) { if (viewgroups)
usergroups = _.intersection(usergroups, viewgroups); usergroups = _.intersection(usergroups, viewgroups);
usergroups = _.uniq(this.userGroups.concat(usergroups)); usergroups = _.uniq(this.userGroups.concat(usergroups));
}
} }
if (this.view && this.view.buttonSort && _.difference(usergroups, this.userGroups).length>0) { if (this.view && this.view.buttonSort && _.difference(usergroups, this.userGroups).length>0) {
this.userGroups = usergroups; this.userGroups = usergroups;
@ -1687,6 +1689,7 @@ define([
setFilterGroups: function (group) { setFilterGroups: function (group) {
Common.Utils.InternalSettings.set(this.appPrefix + "comments-filtergroups", group) Common.Utils.InternalSettings.set(this.appPrefix + "comments-filtergroups", group)
} }
}, Common.Controllers.Comments || {})); }, Common.Controllers.Comments || {}));

View file

@ -57,6 +57,7 @@ define([
userid : 0, userid : 0,
username : 'Guest', username : 'Guest',
parsedName : 'Guest', parsedName : 'Guest',
parsedGroups : undefined,
usercolor : null, usercolor : null,
date : undefined, date : undefined,
quote : '', quote : '',