Skip to content

Commit ad976a6

Browse files
committed
fix: mirror Firestore’s orderBy
1 parent fe6299a commit ad976a6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/reducers/cacheReducer.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,16 @@ const fieldsTransducer = (fields) =>
150150
const orderTransducer = (order) => {
151151
const isFlat = typeof order[0] === 'string';
152152
const orders = isFlat ? [order] : order;
153-
return partialRight.apply(null, [orderBy, ...zip.apply(null, orders)]);
153+
const [fields, direction] = zip(
154+
...orders.map(([field, dir]) => [
155+
(data) =>
156+
typeof data[field] === 'string'
157+
? data[field].toLowerCase()
158+
: data[field],
159+
dir || 'asc',
160+
]),
161+
);
162+
return partialRight(map, (docs) => orderBy(docs, fields, direction));
154163
};
155164

156165
/**
@@ -542,7 +551,7 @@ function cleanOverride(draft, { path, id, data }) {
542551

543552
const initialize = (state, { action, key, path }) =>
544553
produce(state, (draft) => {
545-
const done = mark(`cache.LISTENER_RESPONSE`, key);
554+
const done = mark(`cache.${action.type.replace(/(@@.+\/)/, '')}`, key);
546555
if (!draft.database) {
547556
set(draft, ['database'], {});
548557
set(draft, ['databaseOverrides'], {});

0 commit comments

Comments
 (0)