bug(reducers): subcollection orderBy ordered array not correctly sorted after update
See original GitHub issueDo you want to request a feature or report a bug?
bug
What is the current behavior?
Updating a field of a document in a subcollection, does update correctly the value of the document but not the array sorting. Refreshing returns the correct sorted array.
What is the expected behavior?
The array should be sorted correctly to the current values of the documents in the subcollection.
Which versions of dependencies, and which browser are affected by this issue? Did this work in previous versions or setups?
"firebase": "^5.3.0",
"react-redux": "^5.0.7",
"react-redux-firebase": "^2.1.6",
"redux-firestore": "^0.5.7"
browser independant
Steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.
Not sure, another issue might be related to this issue, but I will show the code for my specific problem.
firestore index is created for the query:
participants | points DESC wins DESC quotient DESC
connect listeners:
firestoreConnect((props) => [
{
collection: 'tournaments',
doc: props.tournamentId,
subcollections: [{ collection: 'participants' }],
orderBy: [['points', 'desc'],['wins', 'desc'],['quotient', 'desc']],
storeAs: 'participants' + props.tournamentId }
]),
connect(
({ firestore }, props) => ({
participants: firestore.ordered['participants' + props.tournamentId],
)
}
)
If for example points are updated, the points are changed correctly in the array but the array is not correctly sorted due to the update. But participants are correctly sorted after each refresh/tab switch of the component.
There could be an easy solution for my problem, which I am currently cannot find or my expected behavior isn’t implemented yet.
Thanks for help!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:11 (3 by maintainers)
Top GitHub Comments
Hi @prescottprue,
In one listener response where I get a collection (ordered, filtered with a
where
and stored as something) I get:I believe this could be related to that issue.
I was wrong, I am not using orderBy in this case.
This is my listener:
listenEvents: ({ firestore, teamId }) => date => { firestore.setListener({ collection: Team.collection, doc: teamId, subcollections: [{ collection: 'events' }], where: ['END_TIME', '>=', date], storeAs: 'events' }) }
I am using “redux-firestore”: “^0.7.0”
I am not sure how to help you replicate it, because we are using similar listeners and firestore.ordered in other places that work just fine.
Also the issue is there on first load: the first listener response is wrong as explained before, but if I change a document, in some cases, the document_modified changes the modified doc in firestore.ordered AND adds another one.
Is it the first time you here about that kind of issue? Let me know if there is anything in particular that you think would be helpful I shared