Skip to content

Commit

Permalink
fix: move updateStaleTimer to addObserver / removeObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo committed Nov 27, 2024
1 parent f8cd93e commit 6953297
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/query-core/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export class Query<

// Stop the query from being garbage collected
this.clearGcTimeout()
this.updateStaleTimer()

this.#cache.notify({ type: 'observerAdded', query: this, observer })
}
Expand All @@ -380,6 +381,7 @@ export class Query<

this.scheduleGc()
}
this.updateStaleTimer()

this.#cache.notify({ type: 'observerRemoved', query: this, observer })
}
Expand Down
2 changes: 0 additions & 2 deletions packages/query-core/src/queryObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ export class QueryObserver<
}

this.#updateTimers()
this.#currentQuery.updateStaleTimer()
}
}

protected onUnsubscribe(): void {
if (!this.hasListeners()) {
this.#currentQuery.updateStaleTimer()
this.destroy()
}
}
Expand Down

0 comments on commit 6953297

Please sign in to comment.