Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pagination #919

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Comment on lines +180 to +181
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'X-NEXTCLOUD-Offset': offset,
'X-NEXTCLOUD-limit': queryLimit,
'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
Loading