Skip to content

Commit 0bc00b1

Browse files
author
Bobby
committed
fix(immediate-mode): ordered not getting saved on reprocessing
1 parent 1cdf5a9 commit 0bc00b1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/reducers/cacheReducer.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ function reprocessQuerires(draft, path) {
351351
if (!collections.some((coll) => paths.includes(coll))) {
352352
return;
353353
}
354-
355-
set(draft, [key, 'docs'], selectDocuments(draft, draft[key]));
354+
const docs = selectDocuments(draft, draft[key]);
355+
const ordered = docs.map(({ id, path: _path }) => [_path, id]);
356+
set(draft, [key, 'docs'], docs);
357+
set(draft, [key, 'ordered'], ordered);
356358
});
357359

358360
done();

test/unit/reducers/cacheReducer.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ describe('cacheReducer', () => {
272272
expect(pass1.cache.testStoreAs.docs[1]).to.eql(undefined);
273273
expect(pass2.cache.testStoreAs.docs[0]).to.eql(doc1);
274274
expect(pass2.cache.testStoreAs.docs[1]).to.eql(doc2);
275+
276+
expect(pass1.cache.testStoreAs.ordered[1]).to.eql(undefined);
277+
expect(pass2.cache.testStoreAs.ordered[1]).to.eql([doc2.path, doc2.id]);
275278
});
276279

277280
it('remove a document override synchronously', () => {
@@ -718,9 +721,6 @@ describe('cacheReducer', () => {
718721
const pass1 = reducer(initialState, action1);
719722
const pass2 = reducer(pass1, action2);
720723

721-
console.dir(pass1.cache.database.testCollection);
722-
console.dir(pass2.cache.database.testCollection);
723-
724724
expect(pass1.cache.testStoreAs.docs[0]).to.eql(doc2);
725725
expect(pass1.cache.testStoreAs.docs[1]).to.eql(doc1);
726726
expect(pass2.cache.testStoreAs.docs[0]).to.eql(doc1);

0 commit comments

Comments
 (0)