Skip to content

Commit

Permalink
Merge pull request #82 from ProximaEPFL/user-id-provider
Browse files Browse the repository at this point in the history
feat(uidProvider): Add a uid provider
  • Loading branch information
JoachimFavre authored Apr 10, 2024
2 parents 0d6efd6 + 30f4dfa commit 1a5f8a2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/viewmodels/login_view_model.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "package:flutter/widgets.dart";
import "package:hooks_riverpod/hooks_riverpod.dart";
import "package:proxima/models/database/user/user_id_firestore.dart";
import "package:proxima/models/login_user.dart";
import "package:proxima/services/login_service.dart";
import "package:proxima/views/navigation/routes.dart";
Expand All @@ -20,6 +21,12 @@ final isUserLoggedInProvider = Provider<bool>((ref) {
return ref.watch(userProvider).valueOrNull != null;
});

/// Firebase logged in user id provider
final uidProvider = Provider<UserIdFirestore?>((ref) {
final user = ref.watch(userProvider).valueOrNull;
return user == null ? null : UserIdFirestore(value: user.id);
});

/// Login Service provider; dependency injection used for testing purposes
final loginServiceProvider = Provider<LoginService>((ref) {
return LoginService(
Expand Down

0 comments on commit 1a5f8a2

Please sign in to comment.