Skip to content

Commit

Permalink
feat: add pagination
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Sep 11, 2024
1 parent 232077c commit ce9b844
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/models/addressBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ export class AddressBook extends davCollectionShareable(DavCollection) {
* findAllAndFilterBySimpleProperties(['EMAIL', 'UID', 'CATEGORIES', 'FN', 'TEL', 'NICKNAME', 'N'])
*
* @param {string[]} props
* @param offset
* @param limit
* @return {Promise<VCard[]>}
*/
async findAllAndFilterBySimpleProperties(props) {
async findAllAndFilterBySimpleProperties(props, offset = null, limit = 0) {
const children = []
props.forEach((prop) => {
children.push({
Expand All @@ -100,7 +102,7 @@ export class AddressBook extends davCollectionShareable(DavCollection) {
children,
}, {
name: [NS.NEXTCLOUD, 'has-photo'],
}])
}], null, 'anyof', offset, limit)
}

/**
Expand Down Expand Up @@ -128,9 +130,11 @@ export class AddressBook extends davCollectionShareable(DavCollection) {
* @param {object[]} prop
* @param {number} limit
* @param {string} test Either anyof or allof
* @param {number} offset Offset for the query
* @param {number} queryLimit Limit for the query
* @return {Promise<VCard[]>}
*/
async addressbookQuery(filter, prop = null, limit = null, test = 'anyof') {
async addressbookQuery(filter, prop = null, limit = null, test = 'anyof', offset = null, queryLimit = null) {
debug('sending an addressbook-query request')

const [skeleton] = XMLUtility.getRootSkeleton(
Expand Down Expand Up @@ -173,6 +177,8 @@ export class AddressBook extends davCollectionShareable(DavCollection) {

const headers = {
Depth: '1',
'X-NEXTCLOUD-Offset': offset,
'X-NEXTCLOUD-limit': queryLimit,
}
const body = XMLUtility.serialize(skeleton)
const response = await this._request.report(this.url, headers, body)
Expand Down

0 comments on commit ce9b844

Please sign in to comment.