Skip to content

Commit

Permalink
refactor: removed account parameter and init block from `DrawerVi…
Browse files Browse the repository at this point in the history
…ewModel` to avoid null account
  • Loading branch information
joragua committed Jan 9, 2025
1 parent ed52ffb commit 7429081
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,18 @@ import kotlinx.coroutines.launch
import timber.log.Timber

class DrawerViewModel(
getStoredQuotaAsStreamUseCase: GetStoredQuotaAsStreamUseCase,
private val getStoredQuotaAsStreamUseCase: GetStoredQuotaAsStreamUseCase,
private val removeAccountUseCase: RemoveAccountUseCase,
private val getUserQuotasUseCase: GetUserQuotasUseCase,
private val localStorageProvider: LocalStorageProvider,
private val coroutinesDispatcherProvider: CoroutinesDispatcherProvider,
private val contextProvider: ContextProvider,
accountName: String,
) : ViewModel() {

private val _userQuota = MutableStateFlow<Event<UIResult<Flow<UserQuota?>>>?>(null)
val userQuota: StateFlow<Event<UIResult<Flow<UserQuota?>>>?> = _userQuota

init {
fun getUserQuota(accountName: String) {
runUseCaseWithResult(
coroutineDispatcher = coroutinesDispatcherProvider.io,
requiresConnection = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ import timber.log.Timber
*/
abstract class DrawerActivity : ToolbarActivity() {

private val drawerViewModel by viewModel<DrawerViewModel> {
parametersOf(
account?.name
)
}
private val drawerViewModel by viewModel<DrawerViewModel>()
private val capabilitiesViewModel by viewModel<CapabilityViewModel> {
parametersOf(
account?.name
Expand Down Expand Up @@ -460,6 +456,7 @@ abstract class DrawerActivity : ToolbarActivity() {
account = account,
displayRadius = currentAccountAvatarRadiusDimension
)
drawerViewModel.getUserQuota(account.name)
updateQuota()
}
}
Expand Down Expand Up @@ -543,7 +540,6 @@ abstract class DrawerActivity : ToolbarActivity() {
it.isDrawerIndicatorEnabled = true
}
}
updateQuota()
setOnAccountsUpdatedListener()
}

Expand Down

0 comments on commit 7429081

Please sign in to comment.