From 2c7190928323aaafd383620b6256d07c6e83877b Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Wed, 19 Jun 2024 21:24:18 +0200 Subject: [PATCH] some async refactorings --- app/lib/domain/services/app_initialization.dart | 2 +- .../search_browser/presentation/screens/browser.dart | 2 +- .../presentation/widgets/sheets/view_tabs_sheet.dart | 6 ++---- .../settings/presentation/controllers/save_settings.dart | 2 +- .../share_intent/domain/services/sharing_intent.dart | 2 +- app/lib/features/web_view/domain/repositories/web_view.dart | 4 ++-- .../web_view/presentation/widgets/web_view_tab.dart | 4 ++-- app/lib/presentation/controllers/website_title.dart | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/lib/domain/services/app_initialization.dart b/app/lib/domain/services/app_initialization.dart index b3b0282d..d7f8b099 100644 --- a/app/lib/domain/services/app_initialization.dart +++ b/app/lib/domain/services/app_initialization.dart @@ -46,7 +46,7 @@ class AppInitializationService extends _$AppInitializationService { .syncBangGroups(syncInterval: const Duration(days: 7)); } - Future>> _initHosts(Settings settings) async { + FutureOr>> _initHosts(Settings settings) { if (settings.enableContentBlocking) { state = Result.success( ( diff --git a/app/lib/features/search_browser/presentation/screens/browser.dart b/app/lib/features/search_browser/presentation/screens/browser.dart index 14c3155b..85e528b5 100644 --- a/app/lib/features/search_browser/presentation/screens/browser.dart +++ b/app/lib/features/search_browser/presentation/screens/browser.dart @@ -305,7 +305,7 @@ class KagiScreen extends HookConsumerWidget { lastBackButtonPress.value = null; if (activeWebView?.key != null && webViews.length > 1) { - await ref + ref .read(webViewRepositoryProvider.notifier) .closeTab(activeWebView!.key!); return true; diff --git a/app/lib/features/search_browser/presentation/widgets/sheets/view_tabs_sheet.dart b/app/lib/features/search_browser/presentation/widgets/sheets/view_tabs_sheet.dart index 56fd900a..7a91f2af 100644 --- a/app/lib/features/search_browser/presentation/widgets/sheets/view_tabs_sheet.dart +++ b/app/lib/features/search_browser/presentation/widgets/sheets/view_tabs_sheet.dart @@ -29,10 +29,8 @@ class ViewTabsSheet extends HookConsumerWidget { label: const Text('New Tab'), ), TextButton.icon( - onPressed: () async { - await ref - .read(webViewRepositoryProvider.notifier) - .closeAllTabs(); + onPressed: () { + ref.read(webViewRepositoryProvider.notifier).closeAllTabs(); }, icon: const Icon(Icons.delete), label: const Text('Close All'), diff --git a/app/lib/features/settings/presentation/controllers/save_settings.dart b/app/lib/features/settings/presentation/controllers/save_settings.dart index b9bfc5ed..0469191e 100644 --- a/app/lib/features/settings/presentation/controllers/save_settings.dart +++ b/app/lib/features/settings/presentation/controllers/save_settings.dart @@ -11,7 +11,7 @@ class SaveSettingsController extends _$SaveSettingsController { Future save(UpdateSettingsFunc updateSettings) async { state = const AsyncLoading(); state = await AsyncValue.guard( - () async => ref + () => ref .read(settingsRepositoryProvider.notifier) .updateSettings(updateSettings), ); diff --git a/app/lib/features/share_intent/domain/services/sharing_intent.dart b/app/lib/features/share_intent/domain/services/sharing_intent.dart index 63f3bd8d..e2929fda 100644 --- a/app/lib/features/share_intent/domain/services/sharing_intent.dart +++ b/app/lib/features/share_intent/domain/services/sharing_intent.dart @@ -53,7 +53,7 @@ Raw> sharingIntentStream(SharingIntentStreamRef ref) { // ignore: discarded_futures .getInitialSharing() // ignore: discarded_futures - .then((event) async { + .then((event) { FlutterSharingIntent.instance.reset(); return event; }).asStream(); diff --git a/app/lib/features/web_view/domain/repositories/web_view.dart b/app/lib/features/web_view/domain/repositories/web_view.dart index 965f192f..f2a986b1 100644 --- a/app/lib/features/web_view/domain/repositories/web_view.dart +++ b/app/lib/features/web_view/domain/repositories/web_view.dart @@ -35,11 +35,11 @@ class WebViewRepository extends _$WebViewRepository { state = {...state, webView.page.value.key: webView}; } - Future closeTab(Key key) async { + void closeTab(Key key) { state = Map.of(state)..remove(key); } - Future closeAllTabs() async { + void closeAllTabs() { state = {}; } } diff --git a/app/lib/features/web_view/presentation/widgets/web_view_tab.dart b/app/lib/features/web_view/presentation/widgets/web_view_tab.dart index 0c96fe20..c54a122d 100644 --- a/app/lib/features/web_view/presentation/widgets/web_view_tab.dart +++ b/app/lib/features/web_view/presentation/widgets/web_view_tab.dart @@ -60,8 +60,8 @@ class WebViewTab extends HookConsumerWidget { IconButton( visualDensity: const VisualDensity(horizontal: -4.0, vertical: -4.0), - onPressed: () async { - await ref + onPressed: () { + ref .read(webViewRepositoryProvider.notifier) .closeTab(page.key); }, diff --git a/app/lib/presentation/controllers/website_title.dart b/app/lib/presentation/controllers/website_title.dart index 0639116a..52dfe15f 100644 --- a/app/lib/presentation/controllers/website_title.dart +++ b/app/lib/presentation/controllers/website_title.dart @@ -5,7 +5,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'website_title.g.dart'; @Riverpod(keepAlive: true) -Future pageInfo(PageInfoRef ref, Uri url) async { +Future pageInfo(PageInfoRef ref, Uri url) { final websiteService = ref.watch(genericWebsiteServiceProvider.notifier); return websiteService.getInfo(url).then((value) => value.value); }