Skip to content

Commit

Permalink
docs: add/update docs for user deletions functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Romainhir committed Dec 17, 2024
1 parent ee852b6 commit 541faa1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ constructor(
private val eventRepository: EventRepository
) : UserDeletionRepository {

/**
* Initialize the user deletion repository.
*
* @param onSuccess the callback to be called when the initialization is successful.
*/
override fun init(onSuccess: () -> Unit) {
Firebase.auth.registerAuthStateListener {
if (it.currentUser != null) {
Expand All @@ -30,6 +35,16 @@ constructor(
}
}

/**
* Delete the user with the given user ID. This method will also update the events and
* associations that the user is associated with.
*
* @param userId the ID of the user to be deleted.
* @param eventToUpdate the list of events to be updated.
* @param associationToUpdate the list of associations to be updated.
* @param onSuccess the callback to be called when the user is successfully deleted.
* @param onFailure the callback to be called when the user deletion fails.
*/
override fun deleteUser(
userId: String,
eventToUpdate: List<Event>,
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/com/android/unio/model/user/UserViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ constructor(
}

/**
* Deletes the user with the given userId from firebase auth, storage (for the profile picture)
* and firestore
* Deletes the user and from the database and update all its dependencies. If
* [deleteWithProfilePicture] is set to true, the user's profile picture will also be deleted.
*
* @param userId The Id of the corresponding user we want to delete
* @return true if all three method were successful and false otherwise
* @param user The [User] object to delete.
* @param deleteWithProfilePicture Whether to delete the user's profile picture or not.
* @param onSuccess Callback if deletion is successful.
* @param onFailure Callback if deletion fails.
*/
suspend fun deleteUser(
user: User,
Expand Down

0 comments on commit 541faa1

Please sign in to comment.