use fire immediatialy

This commit is contained in:
Fabian Freund
2025-06-15 21:27:41 +02:00
parent 81ecb69cce
commit 9b7286ffd4
6 changed files with 67 additions and 31 deletions
@@ -13,21 +13,25 @@ class CompletePageInfo extends _$CompletePageInfo {
return AsyncData(cached!);
}
ref.listen(pageInfoProvider(url, isImageRequest: false), (previous, next) {
if (cached != null && next.hasValue) {
state = AsyncData(
WebPageInfo(
url: url,
//Cached is preferred as this comes from gecko and is more likely to be correct compared to manual request
favicon: cached.favicon ?? next.value!.favicon,
feeds: cached.feeds ?? next.value!.feeds,
title: cached.title ?? next.value!.title,
),
);
} else {
state = next;
}
});
ref.listen(
fireImmediately: true,
pageInfoProvider(url, isImageRequest: false),
(previous, next) {
if (cached != null && next.hasValue) {
state = AsyncData(
WebPageInfo(
url: url,
//Cached is preferred as this comes from gecko and is more likely to be correct compared to manual request
favicon: cached.favicon ?? next.value!.favicon,
feeds: cached.feeds ?? next.value!.feeds,
title: cached.title ?? next.value!.title,
),
);
} else {
state = next;
}
},
);
return (cached != null) ? AsyncData(cached) : const AsyncLoading();
}