diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-02-01 16:54:18 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-02-02 18:01:15 +0100 |
commit | 64ad99db70a18bafdbcf906dd400db6e0712fe29 (patch) | |
tree | ec62d93f999b021a99d55818cbfa7067c58202e5 /apps/comments | |
parent | fdf555e814f84063c2dfa763a6aa285c52f9443d (diff) | |
download | nextcloud-server-64ad99db70a18bafdbcf906dd400db6e0712fe29.tar.gz nextcloud-server-64ad99db70a18bafdbcf906dd400db6e0712fe29.zip |
Better comments pagination logic
Diffstat (limited to 'apps/comments')
-rw-r--r-- | apps/comments/js/commentcollection.js | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js index eaa7a1d53fa..055752f327c 100644 --- a/apps/comments/js/commentcollection.js +++ b/apps/comments/js/commentcollection.js @@ -30,7 +30,7 @@ _objectId: null, _endReached: false, - _limit : 5, + _limit : 20, initialize: function(models, options) { options = options || {}; @@ -72,15 +72,10 @@ var body = '<?xml version="1.0" encoding="utf-8" ?>\n' + '<D:report xmlns:D="DAV:" xmlns:oc="http://owncloud.org/ns">\n' + - ' <oc:limit>' + this._limit + '</oc:limit>\n'; - - if (this.length > 0) { - body += ' <oc:datetime>' + this.last().get('creationDateTime') + '</oc:datetime>\n'; - } - - body += '</D:report>\n'; - - var oldLength = this.length; + // load one more so we know there is more + ' <oc:limit>' + (this._limit + 1) + '</oc:limit>\n' + + ' <oc:offset>' + this.length + '</oc:offset>\n' + + '</D:report>\n'; options = options || {}; var success = options.success; @@ -89,9 +84,12 @@ data: body, davProperties: CommentsCollection.prototype.model.prototype.davProperties, success: function(resp) { - if (resp.length === oldLength) { + if (resp.length <= self._limit) { // no new entries, end reached self._endReached = true; + } else { + // remove last entry, for next page load + resp = _.initial(resp); } if (!self.set(resp, options)) { return false; |