From 4f08453a2dbe057f6672489e036770d84b9b5eb4 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Sun, 14 May 2023 09:36:18 +0200 Subject: [PATCH] Add getAllFriendships() --- .../implementation/FirebaseFriendshipDAO.kt | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 app/src/main/java/be/ugent/sel/studeez/domain/implementation/FirebaseFriendshipDAO.kt diff --git a/app/src/main/java/be/ugent/sel/studeez/domain/implementation/FirebaseFriendshipDAO.kt b/app/src/main/java/be/ugent/sel/studeez/domain/implementation/FirebaseFriendshipDAO.kt new file mode 100644 index 0000000..4f2203c --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/domain/implementation/FirebaseFriendshipDAO.kt @@ -0,0 +1,49 @@ +package be.ugent.sel.studeez.domain.implementation + +import be.ugent.sel.studeez.data.local.models.Friendship +import be.ugent.sel.studeez.domain.AccountDAO +import be.ugent.sel.studeez.domain.FriendshipDAO +import com.google.firebase.firestore.DocumentReference +import com.google.firebase.firestore.FirebaseFirestore +import com.google.firebase.firestore.ktx.snapshots +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import javax.inject.Inject + +class FirebaseFriendshipDAO @Inject constructor( + private val firestore: FirebaseFirestore, + private val auth: AccountDAO +): FriendshipDAO { + + private fun currentUserDocument(): DocumentReference = firestore + .collection(FirebaseCollections.USER_COLLECTION) + .document(auth.currentUserId) + + override fun getAllFriendships(): Flow> { + return currentUserDocument() + .collection(FirebaseCollections.FRIENDS_COLLECTION) + .snapshots() + .map { it.toObjects(Friendship::class.java) } + } + + override fun getFriendshipCount(): Flow { + TODO("Not yet implemented") + } + + override fun getFriendshipDetails(id: String): Friendship { + TODO("Not yet implemented") + } + + override fun sendFriendshipRequest(id: String): Boolean { + TODO("Not yet implemented") + } + + override fun acceptFriendship(id: String): Boolean { + TODO("Not yet implemented") + } + + override fun removeFriendship(id: String): Boolean { + TODO("Not yet implemented") + } + +} \ No newline at end of file