From 6ee37c0216379d7d465f14e9bfe42d4d9f5b3cbe Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:21:16 -0500 Subject: [PATCH] fix: set profile to public by default (#1840) --- lib/pangea/common/constants/model_keys.dart | 2 +- .../pages/settings_learning.dart | 2 +- .../user/controllers/user_controller.dart | 2 +- lib/pangea/user/models/user_model.dart | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/pangea/common/constants/model_keys.dart b/lib/pangea/common/constants/model_keys.dart index 5e0a1d53f..236300c88 100644 --- a/lib/pangea/common/constants/model_keys.dart +++ b/lib/pangea/common/constants/model_keys.dart @@ -15,7 +15,7 @@ class ModelKey { static const String userInterests = 'interests'; static const String l2LanguageKey = 'target_language'; static const String l1LanguageKey = 'source_language'; - static const String publicProfile = 'public'; + static const String publicProfile = 'public_profile'; static const String userId = 'user_id'; static const String toolSettings = 'tool_settings'; static const String userSettings = 'user_settings'; diff --git a/lib/pangea/learning_settings/pages/settings_learning.dart b/lib/pangea/learning_settings/pages/settings_learning.dart index d032c4b25..9afb854b6 100644 --- a/lib/pangea/learning_settings/pages/settings_learning.dart +++ b/lib/pangea/learning_settings/pages/settings_learning.dart @@ -142,7 +142,7 @@ class SettingsLearningController extends State { ? PangeaLanguage.byLangCode(_profile.userSettings.targetLanguage!) : null; - bool get publicProfile => _profile.userSettings.publicProfile; + bool get publicProfile => _profile.userSettings.publicProfile ?? true; LanguageLevelTypeEnum get cefrLevel => _profile.userSettings.cefrLevel; diff --git a/lib/pangea/user/controllers/user_controller.dart b/lib/pangea/user/controllers/user_controller.dart index 970351bce..a29a615d2 100644 --- a/lib/pangea/user/controllers/user_controller.dart +++ b/lib/pangea/user/controllers/user_controller.dart @@ -286,7 +286,7 @@ class UserController extends BaseController { /// Returns a boolean value indicating whether the user's profile is public. bool get isPublic { - return profile.userSettings.publicProfile; + return profile.userSettings.publicProfile ?? true; } /// Retrieves the user's email address. diff --git a/lib/pangea/user/models/user_model.dart b/lib/pangea/user/models/user_model.dart index da3cfd51c..1eafaa388 100644 --- a/lib/pangea/user/models/user_model.dart +++ b/lib/pangea/user/models/user_model.dart @@ -12,10 +12,10 @@ import '../../learning_settings/models/language_model.dart'; class UserSettings { DateTime? dateOfBirth; DateTime? createdAt; - bool autoPlayMessages; + bool? autoPlayMessages; // bool itAutoPlay; bool activatedFreeTrial; - bool publicProfile; + bool? publicProfile; String? targetLanguage; String? sourceLanguage; String? country; @@ -25,10 +25,10 @@ class UserSettings { UserSettings({ this.dateOfBirth, this.createdAt, - this.autoPlayMessages = false, + this.autoPlayMessages, // this.itAutoPlay = true, this.activatedFreeTrial = false, - this.publicProfile = false, + this.publicProfile, this.targetLanguage, this.sourceLanguage, this.country, @@ -43,10 +43,10 @@ class UserSettings { createdAt: json[ModelKey.userCreatedAt] != null ? DateTime.parse(json[ModelKey.userCreatedAt]) : null, - autoPlayMessages: json[ModelKey.autoPlayMessages] ?? false, + autoPlayMessages: json[ModelKey.autoPlayMessages], // itAutoPlay: json[ModelKey.itAutoPlay] ?? true, activatedFreeTrial: json[ModelKey.activatedTrialKey] ?? false, - publicProfile: json[ModelKey.publicProfile] ?? false, + publicProfile: json[ModelKey.publicProfile], targetLanguage: json[ModelKey.l2LanguageKey], sourceLanguage: json[ModelKey.l1LanguageKey], country: json[ModelKey.userCountry], @@ -351,7 +351,7 @@ class PangeaProfile { String? sourceLanguage; String? country; - bool publicProfile; + bool? publicProfile; PangeaProfile({ required this.createdAt, @@ -360,7 +360,7 @@ class PangeaProfile { this.targetLanguage, this.sourceLanguage, this.country, - this.publicProfile = false, + this.publicProfile, }); factory PangeaProfile.fromJson(Map json) { @@ -377,7 +377,7 @@ class PangeaProfile { dateOfBirth: json[ModelKey.userDateOfBirth], targetLanguage: l2, sourceLanguage: l1, - publicProfile: json[ModelKey.publicProfile] ?? false, + publicProfile: json[ModelKey.publicProfile], country: json[ModelKey.userCountry], ); }