cozy-client 32.2.1 → 32.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CozyClient.js +1 -1
- package/dist/store/queries.js +14 -2
- package/dist/store/queries.spec.js +32 -0
- package/package.json +2 -2
package/dist/CozyClient.js
CHANGED
|
@@ -2550,7 +2550,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2550
2550
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2551
2551
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2552
2552
|
|
|
2553
|
-
CozyClient.version = "32.2.
|
|
2553
|
+
CozyClient.version = "32.2.2";
|
|
2554
2554
|
|
|
2555
2555
|
_microee.default.mixin(CozyClient);
|
|
2556
2556
|
|
package/dist/store/queries.js
CHANGED
|
@@ -120,8 +120,20 @@ var sortAndLimitDocsIds = function sortAndLimitDocsIds(queryState, documents, id
|
|
|
120
120
|
evaluatedIds = sorter(docs).map(_helpers.properId);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
var limit = queryState.definition.limit;
|
|
124
|
+
|
|
125
|
+
if (limit) {
|
|
126
|
+
var sliceCount;
|
|
127
|
+
|
|
128
|
+
if (count < limit) {
|
|
129
|
+
// When there are less results than the limit, this is either the first
|
|
130
|
+
// or last paginated query.
|
|
131
|
+
sliceCount = fetchedPagesCount > 1 ? limit * (fetchedPagesCount - 1) + count : count;
|
|
132
|
+
} else {
|
|
133
|
+
sliceCount = limit * fetchedPagesCount;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
evaluatedIds = evaluatedIds.slice(0, sliceCount);
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
return evaluatedIds;
|
|
@@ -427,4 +427,36 @@ describe('sortAndLimitDocsIds', () => {
|
|
|
427
427
|
)
|
|
428
428
|
expect(ids2).toEqual(['doc2', 'doc1'])
|
|
429
429
|
})
|
|
430
|
+
|
|
431
|
+
it('should correctly handle count inferior to limit', () => {
|
|
432
|
+
const query1 = Q('io.cozy.files')
|
|
433
|
+
.sortBy([{ name: 'asc' }])
|
|
434
|
+
.limitBy(2)
|
|
435
|
+
|
|
436
|
+
const ids1 = sortAndLimitDocsIds(
|
|
437
|
+
{ definition: query1.toDefinition() },
|
|
438
|
+
docs,
|
|
439
|
+
['doc1', 'doc2'],
|
|
440
|
+
{
|
|
441
|
+
count: 1,
|
|
442
|
+
fetchedPagesCount: 1
|
|
443
|
+
}
|
|
444
|
+
)
|
|
445
|
+
expect(ids1.length).toEqual(1)
|
|
446
|
+
|
|
447
|
+
const query2 = Q('io.cozy.files')
|
|
448
|
+
.sortBy([{ name: 'asc' }])
|
|
449
|
+
.limitBy(2)
|
|
450
|
+
|
|
451
|
+
const ids2 = sortAndLimitDocsIds(
|
|
452
|
+
{ definition: query2.toDefinition() },
|
|
453
|
+
docs,
|
|
454
|
+
['doc1', 'doc2', 'doc3'],
|
|
455
|
+
{
|
|
456
|
+
count: 1,
|
|
457
|
+
fetchedPagesCount: 2
|
|
458
|
+
}
|
|
459
|
+
)
|
|
460
|
+
expect(ids2.length).toEqual(3)
|
|
461
|
+
})
|
|
430
462
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "32.2.
|
|
3
|
+
"version": "32.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "0c955a3e9132d1b811aaeb1c868427258209c74a"
|
|
77
77
|
}
|