Skip to content

Commit

Permalink
Optimize user profile row logic in settings (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
banghuazhao authored Nov 17, 2024
1 parent 56d9bbb commit 50df25f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
6 changes: 4 additions & 2 deletions lib/presentation/settings/viewModels/settings_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ class SettingsViewModel extends ChangeNotifier {
required this.userUserCase,
required this.featureFlagProvider}) {
initPackageInfo();
fetchAuthSessionNew();
}


Future<void> fetchAuthSessionNew() async {
try {
isLoggedIn = await authUseCase.isLoggedIn();
notifyListeners();
final isLoggedIn = await authUseCase.isLoggedIn();
if (isLoggedIn) {
fetchUser();
}
Expand All @@ -57,9 +57,11 @@ class SettingsViewModel extends ChangeNotifier {
try {
user = await userUserCase.fetchMe();
print(user);
isLoggedIn = true;
notifyListeners();
} catch (e) {
isLoggedIn = false;
notifyListeners();
}
}

Expand Down
11 changes: 0 additions & 11 deletions lib/presentation/settings/viewModels/user_profile_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,9 @@ class UserProfileViewModel extends ChangeNotifier {
String errorMessage = '';

UserProfileViewModel({required this.authUseCase, required this.userUseCase}) {
fetchUserDetails();
fetchAuthSessionNew();
}

Future<void> fetchUserDetails() async {
setLoading(true);
try {
user = await userUseCase.fetchMe(); // Assuming a getUser method
} catch (e) {
print("Failed to fetch user details: $e");
}
setLoading(false);
}

Future<void> fetchAuthSessionNew() async {
try {
isLoggedIn = await authUseCase.isLoggedIn();
Expand Down

0 comments on commit 50df25f

Please sign in to comment.