package app.closer.data.repository

import app.closer.core.notifications.TokenRegistrar
import app.closer.data.remote.FirestoreUserDataSource
import app.closer.domain.model.User
import app.closer.domain.repository.UserRepository
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.flow.Flow

@Singleton
class UserRepositoryImpl @Inject constructor(
    private val dataSource: FirestoreUserDataSource
) : UserRepository {

    override suspend fun getUser(uid: String): User? = dataSource.getUser(uid)

    override fun observeUser(uid: String): Flow<User?> = dataSource.observeUser(uid)

    override suspend fun createUser(user: User) = dataSource.createUser(user)

    override suspend fun updateDisplayName(uid: String, displayName: String) =
        dataSource.updateDisplayName(uid, displayName)

    override suspend fun updatePhotoUrl(uid: String, photoUrl: String) =
        dataSource.updatePhotoUrl(uid, photoUrl)

    override suspend fun updateSex(uid: String, sex: String) =
        dataSource.updateSex(uid, sex)

    override suspend fun hasProfile(uid: String): Boolean = dataSource.hasProfile(uid)

    override suspend fun storeFcmToken(uid: String, token: String) =
        dataSource.storeFcmToken(uid, token)

    override suspend fun storeTokenMetadata(
        uid: String,
        token: String,
        metadata: TokenRegistrar.DeviceMetadata
    ) = dataSource.storeTokenMetadata(uid, token, metadata)

    override suspend fun updateNotificationPrefs(uid: String, partnerAnswered: Boolean, chatMessage: Boolean) =
        dataSource.updateNotificationPrefs(uid, partnerAnswered, chatMessage)

    override suspend fun clearCoupleId(uid: String) = dataSource.clearCoupleId(uid)

    override suspend fun deleteUserData(uid: String) = dataSource.deleteUserData(uid)
}
