Skip to content

Commit

Permalink
feat: added nullability to all classes that are related with `GetStor…
Browse files Browse the repository at this point in the history
…edQuotaAsStreamUseCase`
  • Loading branch information
joragua committed Dec 18, 2024
1 parent e6d9a43 commit f9c7f99
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface LocalUserDataSource {

fun getQuotaForAccountAsFlow(
accountName: String
): Flow<UserQuota>
): Flow<UserQuota?>

fun getAllUserQuotas(): List<UserQuota>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class OCLocalUserDataSource(
override fun getQuotaForAccount(accountName: String): UserQuota? =
userDao.getQuotaForAccount(accountName = accountName)?.toModel()

override fun getQuotaForAccountAsFlow(accountName: String): Flow<UserQuota> =
userDao.getQuotaForAccountAsFlow(accountName = accountName).map { it.toModel() }
override fun getQuotaForAccountAsFlow(accountName: String): Flow<UserQuota?> =
userDao.getQuotaForAccountAsFlow(accountName = accountName).map { it?.toModel() }

override fun getAllUserQuotas(): List<UserQuota> {
return userDao.getAllUserQuotas().map { userQuotaEntity ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface UserDao {
@Query(SELECT_QUOTA)
fun getQuotaForAccountAsFlow(
accountName: String
): Flow<UserQuotaEntity>
): Flow<UserQuotaEntity?>

@Query(SELECT_ALL_QUOTAS)
fun getAllUserQuotas(): List<UserQuotaEntity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class OCUserRepository(
override fun getStoredUserQuota(accountName: String): UserQuota? =
localUserDataSource.getQuotaForAccount(accountName)

override fun getStoredUserQuotaAsFlow(accountName: String): Flow<UserQuota> =
override fun getStoredUserQuotaAsFlow(accountName: String): Flow<UserQuota?> =
localUserDataSource.getQuotaForAccountAsFlow(accountName)

override fun getAllUserQuotas(): List<UserQuota> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface UserRepository {
fun getUserInfo(accountName: String): UserInfo
fun getUserQuota(accountName: String): UserQuota
fun getStoredUserQuota(accountName: String): UserQuota?
fun getStoredUserQuotaAsFlow(accountName: String): Flow<UserQuota>
fun getStoredUserQuotaAsFlow(accountName: String): Flow<UserQuota?>
fun getAllUserQuotas(): List<UserQuota>
fun getAllUserQuotasAsFlow(): Flow<List<UserQuota>>
fun getUserAvatar(accountName: String): UserAvatar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import kotlinx.coroutines.flow.Flow

class GetStoredQuotaAsStreamUseCase(
private val userRepository: UserRepository
) : BaseUseCase<Flow<UserQuota>, GetStoredQuotaAsStreamUseCase.Params>() {
) : BaseUseCase<Flow<UserQuota?>, GetStoredQuotaAsStreamUseCase.Params>() {

override fun run(params: Params): Flow<UserQuota> =
override fun run(params: Params): Flow<UserQuota?> =
userRepository.getStoredUserQuotaAsFlow(params.accountName)

data class Params(val accountName: String)
Expand Down

0 comments on commit f9c7f99

Please sign in to comment.