Fix sort comments by position
This commit is contained in:
parent
b28c877fe2
commit
96679e292c
|
@ -194,7 +194,7 @@ define([
|
||||||
this.api.asc_registerCallback('asc_onUpdateCommentPosition', _.bind(this.onApiUpdateCommentPosition, this));
|
this.api.asc_registerCallback('asc_onUpdateCommentPosition', _.bind(this.onApiUpdateCommentPosition, this));
|
||||||
this.api.asc_registerCallback('asc_onDocumentPlaceChanged', _.bind(this.onDocumentPlaceChanged, this));
|
this.api.asc_registerCallback('asc_onDocumentPlaceChanged', _.bind(this.onDocumentPlaceChanged, this));
|
||||||
this.api.asc_registerCallback('asc_onDeleteComment', _.bind(this.onDeleteComment, this)); // only for PE, when del or ctrl+x pressed
|
this.api.asc_registerCallback('asc_onDeleteComment', _.bind(this.onDeleteComment, this)); // only for PE, when del or ctrl+x pressed
|
||||||
this.api.asc_registerCallback('asc_onChangePositions', _.bind(this.onApiChangePositions, this)); // change comments position in document
|
this.api.asc_registerCallback('asc_onChangeCommentLogicalPosition', _.bind(this.onApiChangeCommentLogicalPosition, this)); // change comments position in document
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1107,11 +1107,12 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onApiChangePositions: function (uids) {
|
onApiChangeCommentLogicalPosition: function (comments) {
|
||||||
for (var i = 0; i < uids.length; ++i) {
|
for (var uid in comments) {
|
||||||
var id = uids[i],
|
if (comments.hasOwnProperty(uid)) {
|
||||||
comment = this.findComment(id) || this.findCommentInGroup(id);
|
var comment = this.findComment(uid) || this.findCommentInGroup(uid);
|
||||||
comment && comment.set('position', this.api.asc_GetCommentLogicPosition(id));
|
comment && comment.set('position', comments[uid]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
(this.getComparator() === 'position-asc' || this.getComparator() === 'position-desc') && this.updateComments(true);
|
(this.getComparator() === 'position-asc' || this.getComparator() === 'position-desc') && this.updateComments(true);
|
||||||
},
|
},
|
||||||
|
@ -1121,12 +1122,13 @@ define([
|
||||||
updateComments: function (needRender, disableSort, loadText) {
|
updateComments: function (needRender, disableSort, loadText) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.updateCommentsTime = new Date();
|
me.updateCommentsTime = new Date();
|
||||||
|
me.disableSort = !!disableSort;
|
||||||
if (me.timerUpdateComments===undefined)
|
if (me.timerUpdateComments===undefined)
|
||||||
me.timerUpdateComments = setInterval(function(){
|
me.timerUpdateComments = setInterval(function(){
|
||||||
if ((new Date()) - me.updateCommentsTime>100) {
|
if ((new Date()) - me.updateCommentsTime>100) {
|
||||||
clearInterval(me.timerUpdateComments);
|
clearInterval(me.timerUpdateComments);
|
||||||
me.timerUpdateComments = undefined;
|
me.timerUpdateComments = undefined;
|
||||||
me.updateCommentsView(needRender, disableSort, loadText);
|
me.updateCommentsView(needRender, me.disableSort, loadText);
|
||||||
}
|
}
|
||||||
}, 25);
|
}, 25);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue