Integrate defaultListingType

This commit is contained in:
shilangyu 2021-04-16 21:59:51 +02:00
parent 270702192e
commit fa7effcb4b
2 changed files with 8 additions and 5 deletions

View File

@ -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,
);
}

View File

@ -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;