From 25d967a7cde35b139ae133cbfd3d540d5458b839 Mon Sep 17 00:00:00 2001 From: Micah Morrison Date: Thu, 11 Apr 2024 12:13:04 -0400 Subject: [PATCH] Add support for new sort types as defaults --- lib/community/widgets/community_drawer.dart | 8 ++-- lib/core/singletons/lemmy_client.dart | 46 ++++++++++++++----- lib/feed/utils/utils.dart | 4 +- lib/feed/view/feed_page.dart | 2 +- lib/feed/widgets/feed_fab.dart | 4 +- lib/feed/widgets/feed_page_app_bar.dart | 4 ++ lib/post/bloc/post_bloc.dart | 2 + lib/post/pages/post_page.dart | 4 +- lib/search/pages/search_page.dart | 1 + lib/settings/pages/general_settings_page.dart | 22 ++++----- lib/shared/comment_sort_picker.dart | 36 +++++++-------- lib/shared/sort_picker.dart | 39 ++++++++-------- lib/thunder/bloc/thunder_state.dart | 1 + lib/thunder/pages/thunder_page.dart | 4 +- 14 files changed, 103 insertions(+), 74 deletions(-) diff --git a/lib/community/widgets/community_drawer.dart b/lib/community/widgets/community_drawer.dart index 72d52af10..a122fc5a1 100644 --- a/lib/community/widgets/community_drawer.dart +++ b/lib/community/widgets/community_drawer.dart @@ -177,7 +177,7 @@ class FeedDrawerItems extends StatelessWidget { isSelected: destination.listingType == feedState.postListingType, onTap: () { Navigator.of(context).pop(); - navigateToFeedPage(context, feedType: FeedType.general, postListingType: destination.listingType, sortType: thunderState.defaultSortType); + navigateToFeedPage(context, feedType: FeedType.general, postListingType: destination.listingType, sortType: thunderState.sortTypeForInstance); }, label: destination.label, icon: destination.icon, @@ -264,7 +264,7 @@ class FavoriteCommunities extends StatelessWidget { context.read().add( FeedFetchedEvent( feedType: FeedType.community, - sortType: thunderState.defaultSortType, + sortType: thunderState.sortTypeForInstance, communityId: community.id, reset: true, ), @@ -341,7 +341,7 @@ class SubscribedCommunities extends StatelessWidget { context.read().add( FeedFetchedEvent( feedType: FeedType.community, - sortType: thunderState.defaultSortType, + sortType: thunderState.sortTypeForInstance, communityId: community.id, reset: true, ), @@ -411,7 +411,7 @@ class ModeratedCommunities extends StatelessWidget { context.read().add( FeedFetchedEvent( feedType: FeedType.community, - sortType: thunderState.defaultSortType, + sortType: thunderState.sortTypeForInstance, communityId: community.id, reset: true, ), diff --git a/lib/core/singletons/lemmy_client.dart b/lib/core/singletons/lemmy_client.dart index 1b4a74f6f..4a4110c42 100644 --- a/lib/core/singletons/lemmy_client.dart +++ b/lib/core/singletons/lemmy_client.dart @@ -32,22 +32,50 @@ class LemmyClient { ); } - bool supportsFeature(LemmyFeature feature) { - if (!_lemmySites.containsKey(instance.lemmyApiV3.host)) return false; + Version? get version { + if (!_lemmySites.containsKey(instance.lemmyApiV3.host)) return null; // Parse the version GetSiteResponse site = _lemmySites[instance.lemmyApiV3.host]!; - Version instanceVersion; try { - instanceVersion = Version.parse(site.version); + return Version.parse(site.version); } catch (e) { - return false; + return null; } + } + + bool supportsSortType(SortType? sortType) => switch (sortType) { + SortType.controversial => supportsFeature(LemmyFeature.sortTypeControversial), + SortType.scaled => supportsFeature(LemmyFeature.sortTypeScaled), + _ => true, + }; + + bool supportsCommentSortType(CommentSortType commentSortType) => switch (commentSortType) { + CommentSortType.controversial => supportsFeature(LemmyFeature.commentSortTypeControversial), + _ => true, + }; + + bool supportsFeature(LemmyFeature feature) { + if (version == null) return false; + + // Check the feature and return whether it's supported in this version + return version! >= feature.minSupportedVersion; + } + + static bool versionSupportsFeature(Version? version, LemmyFeature feature) { + if (version == null) return false; + + if (version == maxVersion) return true; // Check the feature and return whether it's supported in this version - return instanceVersion > feature.minSupportedVersion; + return version >= feature.minSupportedVersion; } + /// This is a special Version object which simulates a "maximum possible version". + /// Note that it doesn't actually work as a max version in terms of comparison, + /// but it can be reference checked. + static Version maxVersion = Version(0, 0, 0, build: "max-version"); + String generatePostUrl(int id) => 'https://${lemmyApiV3.host}/post/$id'; String generateCommentUrl(int id) => 'https://${lemmyApiV3.host}/comment/$id'; @@ -81,9 +109,3 @@ enum LemmyFeature { preRelease: List.from(preRelease), ); } - -enum IncludeVersionSpecificFeature { - never, - ifSupported, - always, -} diff --git a/lib/feed/utils/utils.dart b/lib/feed/utils/utils.dart index fc42ccd95..9f69de2d1 100644 --- a/lib/feed/utils/utils.dart +++ b/lib/feed/utils/utils.dart @@ -87,7 +87,7 @@ Future navigateToFeedPage( FeedFetchedEvent( feedType: feedType, postListingType: postListingType, - sortType: sortType ?? thunderBloc.state.defaultSortType, + sortType: sortType ?? thunderBloc.state.sortTypeForInstance, communityId: communityId, communityName: communityName, userId: userId, @@ -118,7 +118,7 @@ Future navigateToFeedPage( child: Material( child: FeedPage( feedType: feedType, - sortType: sortType ?? thunderBloc.state.defaultSortType, + sortType: sortType ?? thunderBloc.state.sortTypeForInstance, communityName: communityName, communityId: communityId, userId: userId, diff --git a/lib/feed/view/feed_page.dart b/lib/feed/view/feed_page.dart index e2cc1259e..531bafbe6 100644 --- a/lib/feed/view/feed_page.dart +++ b/lib/feed/view/feed_page.dart @@ -559,7 +559,7 @@ class _FeedViewState extends State { if (!canPop && (desiredListingType != currentListingType || communityMode)) { feedBloc.add( FeedFetchedEvent( - sortType: thunderBloc.state.defaultSortType, + sortType: thunderBloc.state.sortTypeForInstance, reset: true, postListingType: desiredListingType, feedType: FeedType.general, diff --git a/lib/feed/widgets/feed_fab.dart b/lib/feed/widgets/feed_fab.dart index adfe341ac..2aee105e5 100644 --- a/lib/feed/widgets/feed_fab.dart +++ b/lib/feed/widgets/feed_fab.dart @@ -6,12 +6,11 @@ import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:lemmy_api_client/v3.dart'; -import 'package:swipeable_page_route/swipeable_page_route.dart'; import 'package:thunder/account/bloc/account_bloc.dart'; -import 'package:thunder/community/pages/create_post_page.dart'; import 'package:thunder/core/auth/bloc/auth_bloc.dart'; import 'package:thunder/core/enums/fab_action.dart'; +import 'package:thunder/core/singletons/lemmy_client.dart'; import 'package:thunder/feed/bloc/feed_bloc.dart'; import 'package:thunder/feed/utils/utils.dart'; import 'package:thunder/feed/view/feed_page.dart'; @@ -287,6 +286,7 @@ class FeedFAB extends StatelessWidget { title: l10n.sortOptions, onSelect: (selected) async => context.read().add(FeedChangeSortTypeEvent(selected.payload)), previouslySelected: context.read().state.sortType, + minimumVersion: LemmyClient.instance.version, ), ); } diff --git a/lib/feed/widgets/feed_page_app_bar.dart b/lib/feed/widgets/feed_page_app_bar.dart index 8c69a766e..40ee80c26 100644 --- a/lib/feed/widgets/feed_page_app_bar.dart +++ b/lib/feed/widgets/feed_page_app_bar.dart @@ -13,6 +13,7 @@ import 'package:thunder/community/bloc/anonymous_subscriptions_bloc.dart'; import 'package:thunder/community/bloc/community_bloc.dart'; import 'package:thunder/community/enums/community_action.dart'; import 'package:thunder/core/auth/bloc/auth_bloc.dart'; +import 'package:thunder/core/singletons/lemmy_client.dart'; import 'package:thunder/feed/bloc/feed_bloc.dart'; import 'package:thunder/feed/utils/community.dart'; import 'package:thunder/feed/utils/community_share.dart'; @@ -167,6 +168,7 @@ class FeedAppBarCommunityActions extends StatelessWidget { title: l10n.sortOptions, onSelect: (selected) async => feedBloc.add(FeedChangeSortTypeEvent(selected.payload)), previouslySelected: feedBloc.state.sortType, + minimumVersion: LemmyClient.instance.version, ), ); }, @@ -262,6 +264,7 @@ class FeedAppBarUserActions extends StatelessWidget { title: l10n.sortOptions, onSelect: (selected) async => feedBloc.add(FeedChangeSortTypeEvent(selected.payload)), previouslySelected: feedBloc.state.sortType, + minimumVersion: LemmyClient.instance.version, ), ); }, @@ -317,6 +320,7 @@ class FeedAppBarGeneralActions extends StatelessWidget { title: l10n.sortOptions, onSelect: (selected) async => feedBloc.add(FeedChangeSortTypeEvent(selected.payload)), previouslySelected: feedBloc.state.sortType, + minimumVersion: LemmyClient.instance.version, ), ); }, diff --git a/lib/post/bloc/post_bloc.dart b/lib/post/bloc/post_bloc.dart index e2cacb080..960332aae 100644 --- a/lib/post/bloc/post_bloc.dart +++ b/lib/post/bloc/post_bloc.dart @@ -100,6 +100,7 @@ class PostBloc extends Bloc { SharedPreferences prefs = await SharedPreferences.getInstance(); CommentSortType defaultSortType = CommentSortType.values.byName(prefs.getString(LocalSettings.defaultCommentSortType.name)?.toLowerCase() ?? DEFAULT_COMMENT_SORT_TYPE.name); + defaultSortType = LemmyClient.instance.supportsCommentSortType(defaultSortType) ? defaultSortType : DEFAULT_COMMENT_SORT_TYPE; Account? account = await fetchActiveProfileAccount(); @@ -226,6 +227,7 @@ class PostBloc extends Bloc { SharedPreferences prefs = await SharedPreferences.getInstance(); CommentSortType defaultSortType = CommentSortType.values.byName(prefs.getString(LocalSettings.defaultCommentSortType.name)?.toLowerCase() ?? DEFAULT_COMMENT_SORT_TYPE.name); + defaultSortType = LemmyClient.instance.supportsCommentSortType(defaultSortType) ? defaultSortType : DEFAULT_COMMENT_SORT_TYPE; CommentSortType sortType = event.sortType ?? (state.sortType ?? defaultSortType); diff --git a/lib/post/pages/post_page.dart b/lib/post/pages/post_page.dart index e007124fa..f4e20b1e6 100644 --- a/lib/post/pages/post_page.dart +++ b/lib/post/pages/post_page.dart @@ -129,8 +129,7 @@ class _PostPageState extends State { if (previousState.sortType != currentState.sortType) { setState(() { sortType = currentState.sortType; - final sortTypeItem = CommentSortPicker.getCommentSortTypeItems(includeVersionSpecificFeature: IncludeVersionSpecificFeature.always) - .firstWhere((sortTypeItem) => sortTypeItem.payload == currentState.sortType); + final sortTypeItem = CommentSortPicker.getCommentSortTypeItems(minimumVersion: LemmyClient.maxVersion).firstWhere((sortTypeItem) => sortTypeItem.payload == currentState.sortType); sortTypeIcon = sortTypeItem.icon; sortTypeLabel = sortTypeItem.label; }); @@ -567,6 +566,7 @@ class _PostPageState extends State { //Navigator.of(context).pop(); }, previouslySelected: sortType, + minimumVersion: LemmyClient.instance.version, ), ); } diff --git a/lib/search/pages/search_page.dart b/lib/search/pages/search_page.dart index 6e0db8dec..9ec003f4c 100644 --- a/lib/search/pages/search_page.dart +++ b/lib/search/pages/search_page.dart @@ -816,6 +816,7 @@ class _SearchPageState extends State with AutomaticKeepAliveClientMi _doSearch(); }, previouslySelected: sortType, + minimumVersion: LemmyClient.instance.version, ), ); } diff --git a/lib/settings/pages/general_settings_page.dart b/lib/settings/pages/general_settings_page.dart index 9daf80fe8..8fb54239b 100644 --- a/lib/settings/pages/general_settings_page.dart +++ b/lib/settings/pages/general_settings_page.dart @@ -28,6 +28,7 @@ import 'package:thunder/utils/bottom_sheet_list_picker.dart'; import 'package:thunder/utils/constants.dart'; import 'package:thunder/utils/language/language.dart'; import 'package:thunder/utils/links.dart'; +import 'package:version/version.dart'; class GeneralSettingsPage extends StatefulWidget { final LocalSettings? settingToHighlight; @@ -329,12 +330,15 @@ class _GeneralSettingsPageState extends State with SingleTi child: ListOption( description: l10n.defaultFeedSortType, value: ListPickerItem(label: defaultSortType.value, icon: Icons.local_fire_department_rounded, payload: defaultSortType), - options: [...SortPicker.getDefaultSortTypeItems(includeVersionSpecificFeature: IncludeVersionSpecificFeature.never), ...topSortTypeItems], + options: [ + ...SortPicker.getDefaultSortTypeItems(minimumVersion: Version(0, 19, 0, preRelease: ["rc", "1"])), + ...topSortTypeItems + ], icon: Icons.sort_rounded, onChanged: (_) async {}, isBottomModalScrollControlled: true, customListPicker: SortPicker( - includeVersionSpecificFeature: IncludeVersionSpecificFeature.never, + minimumVersion: Version(0, 19, 0, preRelease: ["rc", "1"]), title: l10n.defaultFeedSortType, onSelect: (value) async { setPreferences(LocalSettings.defaultFeedSortType, value.payload.name); @@ -358,11 +362,11 @@ class _GeneralSettingsPageState extends State with SingleTi child: ListOption( description: l10n.defaultCommentSortType, value: ListPickerItem(label: defaultCommentSortType.value, icon: Icons.local_fire_department_rounded, payload: defaultCommentSortType), - options: CommentSortPicker.getCommentSortTypeItems(includeVersionSpecificFeature: IncludeVersionSpecificFeature.never), + options: CommentSortPicker.getCommentSortTypeItems(minimumVersion: Version(0, 19, 0, preRelease: ["rc", "1"])), icon: Icons.comment_bank_rounded, onChanged: (_) async {}, customListPicker: CommentSortPicker( - includeVersionSpecificFeature: IncludeVersionSpecificFeature.never, + minimumVersion: Version(0, 19, 0, preRelease: ["rc", "1"]), title: l10n.commentSortType, onSelect: (value) async { setPreferences(LocalSettings.defaultCommentSortType, value.payload.name); @@ -371,16 +375,10 @@ class _GeneralSettingsPageState extends State with SingleTi ), valueDisplay: Row( children: [ - Icon( - CommentSortPicker.getCommentSortTypeItems(includeVersionSpecificFeature: IncludeVersionSpecificFeature.always) - .firstWhere((sortTypeItem) => sortTypeItem.payload == defaultCommentSortType) - .icon, - size: 13), + Icon(CommentSortPicker.getCommentSortTypeItems(minimumVersion: LemmyClient.maxVersion).firstWhere((sortTypeItem) => sortTypeItem.payload == defaultCommentSortType).icon, size: 13), const SizedBox(width: 4), Text( - CommentSortPicker.getCommentSortTypeItems(includeVersionSpecificFeature: IncludeVersionSpecificFeature.always) - .firstWhere((sortTypeItem) => sortTypeItem.payload == defaultCommentSortType) - .label, + CommentSortPicker.getCommentSortTypeItems(minimumVersion: LemmyClient.maxVersion).firstWhere((sortTypeItem) => sortTypeItem.payload == defaultCommentSortType).label, style: theme.textTheme.titleSmall, ), ], diff --git a/lib/shared/comment_sort_picker.dart b/lib/shared/comment_sort_picker.dart index 0da9d06d5..6fbb94fc9 100644 --- a/lib/shared/comment_sort_picker.dart +++ b/lib/shared/comment_sort_picker.dart @@ -5,11 +5,16 @@ import 'package:thunder/shared/picker_item.dart'; import 'package:thunder/utils/bottom_sheet_list_picker.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:thunder/utils/global_context.dart'; +import 'package:version/version.dart'; +/// Create a picker which allows selecting a valid comment sort type. +/// Specify a [minimumVersion] to determine which sort types will be displayed. +/// Pass `null` to NOT show any version-specific types (e.g., Scaled). +/// Pass [LemmyClient.maxVersion] to show ALL types. class CommentSortPicker extends BottomSheetListPicker { - final IncludeVersionSpecificFeature includeVersionSpecificFeature; + final Version? minimumVersion; - static List> getCommentSortTypeItems({IncludeVersionSpecificFeature includeVersionSpecificFeature = IncludeVersionSpecificFeature.ifSupported}) => [ + static List> getCommentSortTypeItems({required Version? minimumVersion}) => [ ListPickerItem( payload: CommentSortType.hot, icon: Icons.local_fire_department, @@ -20,8 +25,7 @@ class CommentSortPicker extends BottomSheetListPicker { icon: Icons.military_tech, label: AppLocalizations.of(GlobalContext.context)!.top, ), - if (includeVersionSpecificFeature == IncludeVersionSpecificFeature.always || - (includeVersionSpecificFeature == IncludeVersionSpecificFeature.ifSupported && LemmyClient.instance.supportsFeature(LemmyFeature.commentSortTypeControversial))) + if (LemmyClient.versionSupportsFeature(minimumVersion, LemmyFeature.commentSortTypeControversial)) ListPickerItem( payload: CommentSortType.controversial, icon: Icons.warning_rounded, @@ -37,22 +41,16 @@ class CommentSortPicker extends BottomSheetListPicker { icon: Icons.access_time_outlined, label: AppLocalizations.of(GlobalContext.context)!.old, ), - // - // ListPickerItem( - // payload: CommentSortType.chat, - // icon: Icons.chat, - // label: 'Chat', - // ), ]; - CommentSortPicker( - {super.key, - required super.onSelect, - required super.title, - List>? items, - super.previouslySelected, - this.includeVersionSpecificFeature = IncludeVersionSpecificFeature.ifSupported}) - : super(items: items ?? CommentSortPicker.getCommentSortTypeItems(includeVersionSpecificFeature: includeVersionSpecificFeature)); + CommentSortPicker({ + super.key, + required super.onSelect, + required super.title, + List>? items, + super.previouslySelected, + required this.minimumVersion, + }) : super(items: items ?? CommentSortPicker.getCommentSortTypeItems(minimumVersion: minimumVersion)); @override State createState() => _SortPickerState(); @@ -96,7 +94,7 @@ class _SortPickerState extends State { shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), children: [ - ..._generateList(CommentSortPicker.getCommentSortTypeItems(includeVersionSpecificFeature: widget.includeVersionSpecificFeature), theme), + ..._generateList(CommentSortPicker.getCommentSortTypeItems(minimumVersion: widget.minimumVersion), theme), ], ), const SizedBox(height: 16.0), diff --git a/lib/shared/sort_picker.dart b/lib/shared/sort_picker.dart index b00075d5c..3fadafaa9 100644 --- a/lib/shared/sort_picker.dart +++ b/lib/shared/sort_picker.dart @@ -5,6 +5,7 @@ import 'package:thunder/shared/picker_item.dart'; import 'package:thunder/utils/bottom_sheet_list_picker.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:thunder/utils/global_context.dart'; +import 'package:version/version.dart'; List> topSortTypeItems = [ ListPickerItem( @@ -64,12 +65,12 @@ List> topSortTypeItems = [ ), ]; -List> allSortTypeItems = [...SortPicker.getDefaultSortTypeItems(includeVersionSpecificFeature: IncludeVersionSpecificFeature.always), ...topSortTypeItems]; +List> allSortTypeItems = [...SortPicker.getDefaultSortTypeItems(minimumVersion: LemmyClient.maxVersion), ...topSortTypeItems]; class SortPicker extends BottomSheetListPicker { - final IncludeVersionSpecificFeature includeVersionSpecificFeature; + final Version? minimumVersion; - static List> getDefaultSortTypeItems({IncludeVersionSpecificFeature includeVersionSpecificFeature = IncludeVersionSpecificFeature.ifSupported}) => [ + static List> getDefaultSortTypeItems({required Version? minimumVersion}) => [ ListPickerItem( payload: SortType.hot, icon: Icons.local_fire_department_rounded, @@ -80,15 +81,13 @@ class SortPicker extends BottomSheetListPicker { icon: Icons.rocket_launch_rounded, label: AppLocalizations.of(GlobalContext.context)!.active, ), - if (includeVersionSpecificFeature == IncludeVersionSpecificFeature.always || - (includeVersionSpecificFeature == IncludeVersionSpecificFeature.ifSupported && LemmyClient.instance.supportsFeature(LemmyFeature.sortTypeScaled))) + if (LemmyClient.versionSupportsFeature(minimumVersion, LemmyFeature.sortTypeScaled)) ListPickerItem( payload: SortType.scaled, icon: Icons.line_weight_rounded, label: AppLocalizations.of(GlobalContext.context)!.scaled, ), - if (includeVersionSpecificFeature == IncludeVersionSpecificFeature.always || - (includeVersionSpecificFeature == IncludeVersionSpecificFeature.ifSupported && LemmyClient.instance.supportsFeature(LemmyFeature.sortTypeControversial))) + if (LemmyClient.versionSupportsFeature(minimumVersion, LemmyFeature.sortTypeControversial)) ListPickerItem( payload: SortType.controversial, icon: Icons.warning_rounded, @@ -116,14 +115,18 @@ class SortPicker extends BottomSheetListPicker { ), ]; - SortPicker( - {super.key, - required super.onSelect, - required super.title, - List>? items, - super.previouslySelected, - this.includeVersionSpecificFeature = IncludeVersionSpecificFeature.ifSupported}) - : super(items: items ?? getDefaultSortTypeItems(includeVersionSpecificFeature: includeVersionSpecificFeature)); + /// Create a picker which allows selecting a valid sort type. + /// Specify a [minimumVersion] to determine which sort types will be displayed. + /// Pass `null` to NOT show any version-specific types (e.g., Scaled). + /// Pass [LemmyClient.maxVersion] to show ALL types. + SortPicker({ + super.key, + required super.onSelect, + required super.title, + List>? items, + super.previouslySelected, + required this.minimumVersion, + }) : super(items: items ?? getDefaultSortTypeItems(minimumVersion: minimumVersion)); @override State createState() => _SortPickerState(); @@ -138,12 +141,12 @@ class _SortPickerState extends State { child: AnimatedSize( duration: const Duration(milliseconds: 100), curve: Curves.easeInOut, - child: topSelected ? topSortPicker() : defaultSortPicker(widget.includeVersionSpecificFeature), + child: topSelected ? topSortPicker() : defaultSortPicker(minimumVersion: widget.minimumVersion), ), ); } - Widget defaultSortPicker(IncludeVersionSpecificFeature includeVersionSpecificFeature) { + Widget defaultSortPicker({required Version? minimumVersion}) { final theme = Theme.of(context); return Column( @@ -165,7 +168,7 @@ class _SortPickerState extends State { shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), children: [ - ..._generateList(SortPicker.getDefaultSortTypeItems(includeVersionSpecificFeature: widget.includeVersionSpecificFeature), theme), + ..._generateList(SortPicker.getDefaultSortTypeItems(minimumVersion: widget.minimumVersion), theme), PickerItem( label: AppLocalizations.of(GlobalContext.context)!.top, icon: Icons.military_tech, diff --git a/lib/thunder/bloc/thunder_state.dart b/lib/thunder/bloc/thunder_state.dart index 2c89c22af..e48c1c7bc 100644 --- a/lib/thunder/bloc/thunder_state.dart +++ b/lib/thunder/bloc/thunder_state.dart @@ -164,6 +164,7 @@ class ThunderState extends Equatable { // Default Listing/Sort Settings final ListingType defaultListingType; final SortType defaultSortType; + SortType get sortTypeForInstance => LemmyClient.instance.supportsSortType(defaultSortType) ? defaultSortType : DEFAULT_SORT_TYPE; // NSFW Settings final bool hideNsfwPosts; diff --git a/lib/thunder/pages/thunder_page.dart b/lib/thunder/pages/thunder_page.dart index 8ddd081ea..133135aa2 100644 --- a/lib/thunder/pages/thunder_page.dart +++ b/lib/thunder/pages/thunder_page.dart @@ -503,7 +503,7 @@ class _ThunderState extends State { FeedFetchedEvent( feedType: FeedType.general, postListingType: thunderBlocState.defaultListingType, - sortType: thunderBlocState.defaultSortType, + sortType: thunderBlocState.sortTypeForInstance, reset: true, ), ); @@ -638,7 +638,7 @@ class _ThunderState extends State { useGlobalFeedBloc: true, feedType: FeedType.general, postListingType: thunderBlocState.defaultListingType, - sortType: thunderBlocState.defaultSortType, + sortType: thunderBlocState.sortTypeForInstance, scaffoldStateKey: scaffoldStateKey, ), AnimatedOpacity(