fix: state update on unmounted hook and infinite query cache refetch not working
This commit is contained in:
@@ -195,13 +195,13 @@ abstract class BaseQuery<T extends Object, Outside, Error>
|
||||
notifyListeners();
|
||||
return data;
|
||||
}
|
||||
final x = hasData && !isPreviousData;
|
||||
var isOnline = await isNetworkOnline;
|
||||
|
||||
/// if isLoading/isRefetching is true that means its already fetching/
|
||||
/// refetching. So [_execute] again can create a race condition
|
||||
if (isLoading ||
|
||||
isRefetching ||
|
||||
!(await isNetworkOnline) ||
|
||||
(hasData && !isPreviousData)) return data;
|
||||
if (isLoading || isRefetching || !isOnline || (hasData && !isPreviousData))
|
||||
return data;
|
||||
status = QueryStatus.loading;
|
||||
notifyListeners();
|
||||
return execute().then((_) {
|
||||
|
||||
@@ -45,12 +45,14 @@ class _InfiniteQueryBuilderState<T extends Object, Outside,
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
init();
|
||||
QueryBowl.of(context).onInfiniteQueriesUpdate<T, Outside, PageParam>(
|
||||
(infiniteQuery) {
|
||||
(infiniteQuery) async {
|
||||
if (infiniteQuery.queryKey != widget.job.queryKey) return;
|
||||
if (mounted)
|
||||
setState(() {
|
||||
this.infiniteQuery = infiniteQuery;
|
||||
});
|
||||
if (infiniteQuery.isCachedData && !infiniteQuery.fetched)
|
||||
await infiniteQuery.refetchPages();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user