Skip to content

Commit

Permalink
Add fallback for empty userId by using null in Firestore query
Browse files Browse the repository at this point in the history
Add fallback for empty userId by using null in Firestore query
  • Loading branch information
cp-megh-l authored Jan 10, 2025
2 parents 6391d5e + 833ab29 commit 01edeba
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class ApiUserService @Inject constructor(

suspend fun getUser(userId: String): ApiUser? {
return try {
val user = userRef.document(userId).get().await().toObject(ApiUser::class.java)
val user = userRef.document(userId.takeIf { it.isNotBlank() } ?: "null").get().await()
.toObject(ApiUser::class.java)
when {
user == null -> null
currentUser == null || user.id != currentUser.id -> user
Expand Down

0 comments on commit 01edeba

Please sign in to comment.