redux-firestore
redux-firestore copied to clipboard
bug(orderedReducer): ordered collection is not updating if using orderBy with desc
What is the current behavior?
I connect to Firestore like this
firestoreConnect([
{
collection: 'emotions',
orderBy: ['updateDate', 'desc'],
},
]),
then I open the screen with collection and collections are ordered by updateDate (desc). Then if I update a record
newRecord.updateDate = new Date()
firestore
.collection('emotions')
.doc(record.id)
.update({ ...newRecord })
all content of the record will be updated, but not the order

If I go back and open screen again, everything is ordered fine again.

But order works fine if I use orderBy with asc instead of desc
What is the expected behavior? Should update collection order correctly according to it index
Which version of redux-firestore are you using? What about other dependencies? "redux-firestore": "^0.9.0", "react-redux-firebase": "^2.4.1", "react-native": "0.59.10",
This also happens when new documents are added, they’re auto ordered at the end of the query (likely due to lack of order).
I tried to replicate using 0.9.0 and it seemed to be working as expected for me. This test should also cover that case that was reported in #230, so I'm surprised to hear this popped up.
Are you able to provide a Codesandbox or similar where the issue can be replicated?
Looking to make sure this is solved, @sintylapse could you provide a reproduction example using Codesandbox or similar?
Hi, sorry, don't have a time right now. Is it okay if I request reopening this issue if I will be able to reproduce it again and will create reproduction example?
@prescottprue I think I just reproduced this issue in my own app. I've whipped up a sample here: https://codesandbox.io/s/firestore-sort-demo-3izym (relevant code is in components\Sort\Sort.js
. Sorry in advance for the ugliness of my quick hack job, but hopefully it gets the point across.
If you click the button a few times to swap data at indices 0
and 1
, you'll see how the ordered
data gets a bit messy in memory.
I'll try to carve out some time to dig further into this soon myself though, but if you have any thoughts that'd be greatly appreciated.