Last active
August 18, 2020 04:56
-
-
Save yashovardhan99/b6be4a1d0b65363c87033bee90260825 to your computer and use it in GitHub Desktop.
Firebase MVVM Profile Service 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suspend fun getFriends(userId: String): List<User> { | |
val db = FirebaseFirestore.getInstance() | |
return try { | |
db.collection("users") | |
.document(userId) | |
.collection("friends").get().await() | |
.documents.mapNotNull { it.toUser() } | |
} catch (e: Exception) { | |
Log.e(TAG, "Error getting user friends", e) | |
FirebaseCrashlytics.getInstance().log("Error getting user friends") | |
FirebaseCrashlytics.getInstance().setCustomKey("user id", xpertSlug) | |
FirebaseCrashlytics.getInstance().recordException(e) | |
emptyList() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment