a lot of improvements for long polling service and notifications
This commit is contained in:
@@ -6,5 +6,7 @@ interface AccountsRepository {
|
||||
|
||||
suspend fun getAccounts(): List<AccountEntity>
|
||||
|
||||
suspend fun getAccountById(userId: Int): AccountEntity?
|
||||
|
||||
suspend fun storeAccounts(accounts: List<AccountEntity>)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ class AccountsRepositoryImpl(
|
||||
|
||||
override suspend fun getAccounts(): List<AccountEntity> = accountDao.getAll()
|
||||
|
||||
override suspend fun getAccountById(userId: Int): AccountEntity? =
|
||||
accountDao.getById(userId)
|
||||
|
||||
override suspend fun storeAccounts(
|
||||
accounts: List<AccountEntity>
|
||||
) = accountDao.insertAll(accounts)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.meloda.app.fast.data.db
|
||||
|
||||
import com.meloda.app.fast.common.UserConfig
|
||||
import com.meloda.app.fast.model.database.AccountEntity
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class GetCurrentAccountUseCase(private val accountsRepository: AccountsRepository) {
|
||||
|
||||
suspend operator fun invoke(): AccountEntity? = withContext(Dispatchers.IO) {
|
||||
accountsRepository.getAccountById(UserConfig.currentUserId)
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.meloda.app.fast.data.api.users.UsersUseCaseImpl
|
||||
import com.meloda.app.fast.data.api.videos.VideosRepository
|
||||
import com.meloda.app.fast.data.db.AccountsRepository
|
||||
import com.meloda.app.fast.data.db.AccountsRepositoryImpl
|
||||
import com.meloda.app.fast.data.db.GetCurrentAccountUseCase
|
||||
import com.meloda.app.fast.database.di.databaseModule
|
||||
import com.meloda.app.fast.datastore.di.dataStoreModule
|
||||
import com.meloda.app.fast.network.di.networkModule
|
||||
@@ -67,6 +68,7 @@ val dataModule = module {
|
||||
singleOf(::VideosRepository)
|
||||
|
||||
singleOf(::AccountsRepositoryImpl) bind AccountsRepository::class
|
||||
singleOf(::GetCurrentAccountUseCase)
|
||||
|
||||
singleOf(::FriendsRepositoryImpl) bind FriendsRepository::class
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user