selectRecord don't return isLoading when updating
Closed this issue · 3 comments
After update to 5.0.1, selectRecord don't return isLoading
field when updating. I think because, in this version we make fetchTime
don't change when UPDATE but selectRecord
use it to check the record on updating then return isLoading.
Now, my updating icon does not show 😢
right so here's the desired behaviour
-fetch a collection
-fetch a record in the collection, pretend it's on the same page/component - should be cached and load instantly
-send an UPDATE action to the store for the record. now two things should happen
- the record should show up as loading - isLoading is true
- the collection should not show isLoading, and stay the same
- UPDATE_FAILURE: record returns to showing old data or an error, collection stays the same
- UPDATE_SUCCESS: record shows new data, collection re-renders new data.
Let me investigate the best way to make this happen.
Ah ha. Here's my proposed solution:
fetchTime === 0 means "I just fetched this record or collection"
fetchTime === null means "This collection hasn't been fetched yet". I don't think fetchTime === null is currently used for records, just for collections.
- in the UPDATE branch of byId, return to setting fetchTime to 0.
- For collections, change the selector. if fetchTime for all records is recent, set isLoading to false. if fetchTime for any records is 0, treat it like "recent". if fetchTime is not recent, or is null (which I guess means an error), then set isLoading to false for the whole collection .
- Continue to check fetchTime on records like normal.
This is essentially a revert of the previous change, plus changing the collection selector. I probably shoudl have done it like this at first. Thanks for the bug report!
give 5.0.2 or 5.1.1 a try.