From fa7effcb4b6b3c212ca8c455f3b1b2c546b60a52 Mon Sep 17 00:00:00 2001 From: shilangyu Date: Fri, 16 Apr 2021 21:59:51 +0200 Subject: [PATCH] Integrate defaultListingType --- lib/pages/home_tab.dart | 12 ++++++++---- lib/stores/config_store.dart | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/pages/home_tab.dart b/lib/pages/home_tab.dart index b23c419..b74ac8d 100644 --- a/lib/pages/home_tab.dart +++ b/lib/pages/home_tab.dart @@ -25,10 +25,13 @@ class HomeTab extends HookWidget { @override Widget build(BuildContext context) { final accStore = useAccountsStore(); + final defaultListingType = + useConfigStoreSelect((configStore) => configStore.defaultListingType); final selectedList = useState(_SelectedList( - listingType: accStore.hasNoAccount + listingType: accStore.hasNoAccount && + defaultListingType == PostListingType.subscribed ? PostListingType.all - : PostListingType.subscribed)); + : defaultListingType)); final isc = useInfiniteScrollController(); final theme = Theme.of(context); final instancesIcons = useMemoFuture(() async { @@ -54,9 +57,10 @@ class HomeTab extends HookWidget { selectedList.value.listingType == PostListingType.subscribed || !accStore.instances.contains(selectedList.value.instanceHost)) { selectedList.value = _SelectedList( - listingType: accStore.hasNoAccount + listingType: accStore.hasNoAccount && + defaultListingType == PostListingType.subscribed ? PostListingType.all - : PostListingType.subscribed, + : defaultListingType, ); } diff --git a/lib/stores/config_store.dart b/lib/stores/config_store.dart index 4dd121e..471dc23 100644 --- a/lib/stores/config_store.dart +++ b/lib/stores/config_store.dart @@ -144,6 +144,5 @@ class ConfigStore extends ChangeNotifier { SortType _sortTypeFromJson(String? json) => json != null ? SortType.fromJson(json) : SortType.hot; -// String _sortType PostListingType _postListingTypeFromJson(String? json) => json != null ? PostListingType.fromJson(json) : PostListingType.all;