Skip to content

Commit f3816be

Browse files
committed
fix: cumulativeQueryHash option work
1 parent 3dab48f commit f3816be

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.changeset/chilly-states-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"mobx-tanstack-query": patch
3+
---
4+
5+
fixed cumulativeQueryHash work

src/query.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,13 @@ export class Query<
595595
async reset(params?: QueryResetParams, options?: ResetOptions) {
596596
if (this.cumulativeQueryHash) {
597597
return await this.queryClient.resetQueries({
598-
predicate: (query) =>
599-
this.cumulativeQueryKeyHashesSet.has(query.options.queryHash!),
598+
predicate: (query) => {
599+
return (
600+
this.cumulativeQueryKeyHashesSet.has(query.options.queryHash!) &&
601+
query.observers.length === 1 &&
602+
query.observers[0] === this.queryObserver
603+
);
604+
},
600605
...params,
601606
});
602607
}
@@ -615,7 +620,9 @@ export class Query<
615620
if (this.cumulativeQueryHash) {
616621
return this.queryClient.removeQueries({
617622
predicate: (query) =>
618-
this.cumulativeQueryKeyHashesSet.has(query.options.queryHash!),
623+
this.cumulativeQueryKeyHashesSet.has(query.options.queryHash!) &&
624+
query.observers.length === 1 &&
625+
query.observers[0] === this.queryObserver,
619626
...params,
620627
});
621628
}

0 commit comments

Comments
 (0)