Add getAllFriendships()
This commit is contained in:
parent
56427a69af
commit
4f08453a2d
1 changed files with 49 additions and 0 deletions
|
@ -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<List<Friendship>> {
|
||||
return currentUserDocument()
|
||||
.collection(FirebaseCollections.FRIENDS_COLLECTION)
|
||||
.snapshots()
|
||||
.map { it.toObjects(Friendship::class.java) }
|
||||
}
|
||||
|
||||
override fun getFriendshipCount(): Flow<Int> {
|
||||
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")
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue