Bring back show nsfw to manage_account

This commit is contained in:
shilangyu 2021-04-22 19:34:35 +02:00
parent 329bf46921
commit 4519077ae2
4 changed files with 11 additions and 20 deletions

View File

@ -108,6 +108,7 @@ class _ManageAccount extends HookWidget {
useTextEditingController(text: user.person.matrixUserId);
final avatar = useRef(user.person.avatar);
final banner = useRef(user.person.banner);
final showNsfw = useState(user.localUser.showNsfw);
final sendNotificationsToEmail =
useState(user.localUser.sendNotificationsToEmail);
final newPasswordController = useTextEditingController();
@ -134,7 +135,7 @@ class _ManageAccount extends HookWidget {
try {
await LemmyApiV3(user.instanceHost).run(SaveUserSettings(
showNsfw: user.localUser.showNsfw,
showNsfw: showNsfw.value,
theme: user.localUser.theme,
defaultSortType: user.localUser.defaultSortType,
defaultListingType: user.localUser.defaultListingType,
@ -318,6 +319,15 @@ class _ManageAccount extends HookWidget {
obscureText: true,
),
const SizedBox(height: 8),
SwitchListTile.adaptive(
value: showNsfw.value,
onChanged: (checked) {
showNsfw.value = checked;
},
title: Text(L10n.of(context)!.show_nsfw),
dense: true,
),
const SizedBox(height: 8),
SwitchListTile.adaptive(
value: sendNotificationsToEmail.value,
onChanged: (checked) {

View File

@ -159,13 +159,6 @@ class GeneralConfigPage extends HookWidget {
),
),
),
SwitchListTile.adaptive(
title: Text(L10n.of(context)!.show_nsfw),
value: configStore.showNsfw,
onChanged: (checked) {
configStore.showNsfw = checked;
},
),
],
),
);

View File

@ -54,15 +54,6 @@ class ConfigStore extends ChangeNotifier {
save();
}
late bool _showNsfw;
@JsonKey(defaultValue: false)
bool get showNsfw => _showNsfw;
set showNsfw(bool showNsfw) {
_showNsfw = showNsfw;
notifyListeners();
save();
}
late bool _showScores;
@JsonKey(defaultValue: true)
bool get showScores => _showScores;
@ -105,7 +96,6 @@ class ConfigStore extends ChangeNotifier {
// };
_showAvatars = localUserSettings.showAvatars;
_showNsfw = localUserSettings.showNsfw;
// TODO: should these also be imported? If so, how?
// _theme = darkModeLemmyUiThemes.contains(localUserSettings.theme)
// ? ThemeMode.dark

View File

@ -13,7 +13,6 @@ ConfigStore _$ConfigStoreFromJson(Map<String, dynamic> json) {
..amoledDarkMode = json['amoledDarkMode'] as bool? ?? false
..locale = LocaleSerde.fromJson(json['locale'] as String?)
..showAvatars = json['showAvatars'] as bool? ?? true
..showNsfw = json['showNsfw'] as bool? ?? false
..showScores = json['showScores'] as bool? ?? true
..defaultSortType = _sortTypeFromJson(json['defaultSortType'] as String?)
..defaultListingType =
@ -26,7 +25,6 @@ Map<String, dynamic> _$ConfigStoreToJson(ConfigStore instance) =>
'amoledDarkMode': instance.amoledDarkMode,
'locale': LocaleSerde.toJson(instance.locale),
'showAvatars': instance.showAvatars,
'showNsfw': instance.showNsfw,
'showScores': instance.showScores,
'defaultSortType': instance.defaultSortType,
'defaultListingType': instance.defaultListingType,