Skip to content

Commit

Permalink
Remove Subscriptions from default feed type in guest mode (#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahmo authored Jul 13, 2024
1 parent 108605b commit 6cfb84f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/settings/pages/general_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> 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),
],
Expand Down
8 changes: 8 additions & 0 deletions lib/utils/preferences.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<void> performSharedPreferencesMigration() async {
final SharedPreferences prefs = (await UserPreferences.instance).sharedPreferences;
Expand Down Expand Up @@ -106,4 +108,10 @@ Future<void> 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);
}
}

0 comments on commit 6cfb84f

Please sign in to comment.