fix: not updating queryFn on create query's old query and checking stale status after updating queryFn instead of storing the status before
This commit is contained in:
@@ -35,6 +35,7 @@ class QueryClient {
|
||||
),
|
||||
)
|
||||
.cast<DataType, ErrorType, KeyType>();
|
||||
query.updateQueryFn(queryFn);
|
||||
cache.addQuery(query);
|
||||
return query;
|
||||
}
|
||||
|
||||
@@ -153,8 +153,12 @@ class Query<DataType, ErrorType, KeyType>
|
||||
}
|
||||
|
||||
void updateQueryFn(QueryFn<DataType> queryFn) {
|
||||
if (state.queryFn == queryFn) return;
|
||||
// updatedAt is updated with copyWith so storing it
|
||||
// here to check if the query is stale later
|
||||
final stale = state.isStale;
|
||||
state = state.copyWith(queryFn: queryFn);
|
||||
if (state.isStale || refreshConfig.refreshOnQueryFnChange) {
|
||||
if (stale || refreshConfig.refreshOnQueryFnChange) {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user