Skip to content

Commit

Permalink
fix: refetch collection when query changes during initial fetch
Browse files Browse the repository at this point in the history
This fixes an issue where a collection with fetchmode = once once not updated because the query prop changed during the inititial fetch.
  • Loading branch information
thdk committed Oct 3, 2022
1 parent bb8707e commit b6ce3dd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/collection/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ export class Collection<T, K = T> {

// New query only needs to trigger fetch docs again if the collection is currently fetched
// The documents will be fetched later with the new query when manually / automatically fetching
if (this.isFetched) {
// In case the initial query was already loading but not yet fetched, starting a new one will dispose the initial query
if (this.isFetched || this.isLoading) {
this.getDocs();
}
})
Expand Down

0 comments on commit b6ce3dd

Please sign in to comment.