Skip to content

Instantly share code, notes, and snippets.

@derysudrajat
Created March 30, 2021 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derysudrajat/930a1c63282b35ba45179e322f281c32 to your computer and use it in GitHub Desktop.
Save derysudrajat/930a1c63282b35ba45179e322f281c32 to your computer and use it in GitHub Desktop.
fun forgetPassword(email: String, isSuccess: (Boolean, message: String) -> Unit) {
Firebase.auth.sendPasswordResetEmail(email)
.addOnCompleteListener {
if (it.isSuccessful) isSuccess(true, "Berhasil Dikirim")
else isSuccess(false, DataHelpers.errorLoginMessage[it.exception?.message] ?: "")
}
}
fun getGroupingChat(uid: String, onResult: (List<GroupChat>) -> Unit) {
Firestore.instance.collection(COLLECTION.CHAT_GROUP)
.whereEqualTo("to", uid)
.orderBy("time", Query.Direction.DESCENDING)
.addSnapshotListener { value, error ->
if (error != null) Log.d(TAG, "getGroupingChat:error = ${error.message}")
if (value != null && !value.isEmpty) {
onResult(value.toObjects(GroupChat::class.java))
} else {
onResult(listOf())
Log.d(TAG, "getGroupingChat:failed = ${error?.message}")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment