Skip to content

bug(reducers): subcollection orderBy ordered array not correctly sorted after update #121

Open
@jollyBaker

Description

Do 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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions