Merge branch 'development' into timers

This commit is contained in:
lbarraga 2023-04-17 11:57:33 +02:00 committed by GitHub Enterprise
commit ce001898fd
17 changed files with 229 additions and 38 deletions

View file

@ -29,5 +29,6 @@ interface AccountDAO {
suspend fun sendRecoveryEmail(email: String)
suspend fun signUpWithEmailAndPassword(email: String, password: String)
suspend fun deleteAccount()
suspend fun signOut()
}

View file

@ -4,4 +4,10 @@ interface UserDAO {
suspend fun getUsername(): String?
suspend fun save(newUsername: String)
/**
* Delete all references to this user in the database. Similar to the deleteCascade in
* relational databases.
*/
suspend fun deleteUserReferences()
}

View file

@ -1,19 +1,13 @@
package be.ugent.sel.studeez.domain.implementation
import androidx.compose.runtime.rememberCoroutineScope
import be.ugent.sel.studeez.R
import be.ugent.sel.studeez.common.snackbar.SnackbarManager
import be.ugent.sel.studeez.domain.AccountDAO
import be.ugent.sel.studeez.domain.UserDAO
import com.google.firebase.firestore.DocumentReference
import com.google.firebase.firestore.FirebaseFirestore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.tasks.await
import javax.inject.Inject
import kotlin.coroutines.coroutineContext
class FirebaseUserDAO @Inject constructor(
private val firestore: FirebaseFirestore,
@ -34,4 +28,10 @@ class FirebaseUserDAO @Inject constructor(
companion object {
private const val USER_COLLECTION = "users"
}
override suspend fun deleteUserReferences() {
currentUserDocument().delete()
.addOnSuccessListener { SnackbarManager.showMessage(R.string.success) }
.addOnFailureListener { SnackbarManager.showMessage(R.string.generic_error) }
}
}