From 6cfb84f1b03f45e2be94f66609766f2eef7924d0 Mon Sep 17 00:00:00 2001 From: Micah Morrison Date: Sat, 13 Jul 2024 13:01:36 -0400 Subject: [PATCH] Remove Subscriptions from default feed type in guest mode (#1490) --- lib/settings/pages/general_settings_page.dart | 1 - lib/utils/preferences.dart | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/settings/pages/general_settings_page.dart b/lib/settings/pages/general_settings_page.dart index bd5420970..8301327f5 100644 --- a/lib/settings/pages/general_settings_page.dart +++ b/lib/settings/pages/general_settings_page.dart @@ -368,7 +368,6 @@ class _GeneralSettingsPageState extends State with SingleTi description: l10n.defaultFeedType, value: ListPickerItem(label: defaultListingType.value, icon: Icons.feed, payload: defaultListingType), options: [ - ListPickerItem(icon: Icons.view_list_rounded, label: ListingType.subscribed.value, payload: ListingType.subscribed), ListPickerItem(icon: Icons.home_rounded, label: ListingType.all.value, payload: ListingType.all), ListPickerItem(icon: Icons.grid_view_rounded, label: ListingType.local.value, payload: ListingType.local), ], diff --git a/lib/utils/preferences.dart b/lib/utils/preferences.dart index 42e4244a9..9ec47e8fa 100644 --- a/lib/utils/preferences.dart +++ b/lib/utils/preferences.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; +import 'package:lemmy_api_client/v3.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:thunder/account/models/draft.dart'; import 'package:thunder/comment/view/create_comment_page.dart'; @@ -11,6 +12,7 @@ import 'package:thunder/core/enums/local_settings.dart'; import 'package:thunder/drafts/draft_type.dart'; import 'package:thunder/notification/enums/notification_type.dart'; import 'package:thunder/core/singletons/preferences.dart'; +import 'package:thunder/utils/constants.dart'; Future performSharedPreferencesMigration() async { final SharedPreferences prefs = (await UserPreferences.instance).sharedPreferences; @@ -106,4 +108,10 @@ Future performSharedPreferencesMigration() async { debugPrint('Cannot migrate draft from SharedPreferences: $draftKey'); } } + + // Update the default feed type setting + ListingType defaultListingType = ListingType.values.byName(prefs.getString(LocalSettings.defaultFeedListingType.name) ?? DEFAULT_LISTING_TYPE.name); + if (defaultListingType == ListingType.subscribed) { + await prefs.setString(LocalSettings.defaultFeedListingType.name, DEFAULT_LISTING_TYPE.name); + } }