Skip to content

Commit

Permalink
fix: Only refetch fetched queries
Browse files Browse the repository at this point in the history
  • Loading branch information
k-ode committed Apr 25, 2024
1 parent 038071e commit 3708255
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/mst-query/src/MstQueryHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,20 @@ export class MstQueryHandler {
}

invalidate() {
const isFetched = this.isFetched;

const refetchQuery = async () => {
const next = await this.refetch();
next();
};

this.cachedAt = undefined;

if (this.isFetched) {
if (isFetched) {
this.isFetched = false;
}

if (this.queryObservers.length > 0) {
if (isFetched && this.queryObservers.length > 0) {
refetchQuery();
}
}
Expand Down

0 comments on commit 3708255

Please sign in to comment.