Mova-100 Remove callbacks from using Firebase functions.
tolgaprm opened this issue · comments
Example
Remove the code
override fun addMovieToFavoriteList(
userUid: String,
data: Map<String, List<Movie>>,
onSuccess: () -> Unit,
onFailure: (uiText: UiText) -> Unit,
) {
firestore.collection(userUid).document(Constants.FIREBASE_FAVORITE_MOVIE_DOCUMENT_NAME)
.set(data.toConvertToFavoriteMovieMap(), SetOptions.merge())
.addOnSuccessListener {
onSuccess()
}.addOnFailureListener { exception ->
setExceptionToFirebaseMessage(exception = exception, onFailure = onFailure)
}
}
override suspend fun addMovieToFavoriteList(
userUid: String,
movieInFavoriteList: List<Movie>
): SimpleResource {
return safeCallWithForFirebase {
val data = mapOf(
FIREBASE_MOVIES_FIELD_NAME to movieInFavoriteList
)
val result =
firestore.collection(userUid)
.document(Constants.FIREBASE_FAVORITE_MOVIE_DOCUMENT_NAME)
.set(data.toConvertToFavoriteMovieMap(), SetOptions.merge())
result.await()
if (result.isSuccessful) {
Resource.Success(Unit)
} else {
Resource.Error(UiText.unknownError())
}
}
}