public profile toggle sets user DOB (#1318)

pull/1544/head
ggurdin 11 months ago committed by GitHub
parent 129c5a5a7a
commit 6491042d59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -34,7 +34,16 @@ class SettingsLearningController extends State<SettingsLearning> {
setPublicProfile(bool isPublic) {
pangeaController.userController.updateProfile(
(profile) {
profile.userSettings.publicProfile = isPublic;
// set user DOB to younger that 18 if private and older than 18 if public
if (isPublic) {
profile.userSettings.dateOfBirth = DateTime.now().subtract(
const Duration(days: 18 * 365),
);
} else {
profile.userSettings.dateOfBirth = DateTime.now().subtract(
const Duration(days: 17 * 365),
);
}
return profile;
},
);
@ -91,7 +100,11 @@ class SettingsLearningController extends State<SettingsLearning> {
}
bool get publicProfile =>
pangeaController.userController.profile.userSettings.publicProfile;
pangeaController.userController.profile.userSettings.dateOfBirth
?.isBefore(
DateTime.now().subtract(const Duration(days: 18 * 365)),
) ??
false;
@override
Widget build(BuildContext context) {

Loading…
Cancel
Save