diff --git a/app/lib/extensions/ref_cache.dart b/app/lib/extensions/ref_cache.dart index 36b2be85..484d804a 100644 --- a/app/lib/extensions/ref_cache.dart +++ b/app/lib/extensions/ref_cache.dart @@ -23,7 +23,7 @@ import 'package:riverpod/riverpod.dart'; extension CacheForExtension on Ref { /// Keeps the provider alive for [duration]. - void cacheFor(Duration duration) { + KeepAliveLink cacheFor(Duration duration) { // Immediately prevent the state from getting destroyed. final link = keepAlive(); // After duration has elapsed, we re-enable automatic disposal. @@ -32,5 +32,7 @@ extension CacheForExtension on Ref { // Optional: when the provider is recomputed (such as with ref.watch), // we cancel the pending timer. onDispose(timer.cancel); + + return link; } } diff --git a/app/lib/presentation/controllers/website_title.dart b/app/lib/presentation/controllers/website_title.dart index 6589faca..ed705b13 100644 --- a/app/lib/presentation/controllers/website_title.dart +++ b/app/lib/presentation/controllers/website_title.dart @@ -81,6 +81,8 @@ Future pageInfo( Uri url, { required bool isImageRequest, }) async { + final link = ref.cacheFor(const Duration(minutes: 2)); + final tabId = ref.read(selectedTabProvider); int? proxyPort; @@ -112,8 +114,8 @@ Future pageInfo( proxyPort: proxyPort, ); - if (result.isSuccess) { - ref.cacheFor(const Duration(minutes: 2)); + if (!result.isSuccess) { + link.close(); } return result.value; diff --git a/app/lib/presentation/controllers/website_title.g.dart b/app/lib/presentation/controllers/website_title.g.dart index 1869d990..f8f71c8d 100644 --- a/app/lib/presentation/controllers/website_title.g.dart +++ b/app/lib/presentation/controllers/website_title.g.dart @@ -6,7 +6,7 @@ part of 'website_title.dart'; // RiverpodGenerator // ************************************************************************** -String _$pageInfoHash() => r'46eec6236555d37b5bbb4d8d887c5ee6ee0336e3'; +String _$pageInfoHash() => r'53380fbf9c67d494944330641cefbde9455cdb60'; /// Copied from Dart SDK class _SystemHash {