-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TECHNICAL] Technical improvements for user quota #4525
base: master
Are you sure you want to change the base?
Conversation
8e7bfe9
to
2f0df52
Compare
…dQuotaAsStreamUseCase`)
… remove unnecessary ones from `DrawerViewModelTest`
1f95f15
to
8d5c35f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good @joragua!! Let's do some changes here 👍
useCase = getStoredQuotaUseCase, | ||
useCaseParams = GetStoredQuotaUseCase.Params(accountName = accountName) | ||
) | ||
val userQuota: Flow<UserQuota> = getStoredQuotaAsStreamUseCase(GetStoredQuotaAsStreamUseCase.Params(accountName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, not sure if I like this... I think it would be better being encapsulated with a private variable. Otherwise everytime we access userQuota
, the use case might be executed, and that's not what we want. Check for example SettingsPictureUploadsViewModel
to see how this is done with the pictureUploads
variable 👍
private val drawerViewModel by viewModel<DrawerViewModel>() | ||
private val drawerViewModel by viewModel<DrawerViewModel> { | ||
parametersOf( | ||
account?.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if account
is null? Did you check where this value is set in BaseActivity
?
is UIResult.Loading -> getAccountQuotaText()?.text = getString(R.string.drawer_loading_quota) | ||
is UIResult.Error -> getAccountQuotaText()?.text = getString(R.string.drawer_unavailable_used_storage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're losing these 2 cases!! We shouldn't, they are so necessary
getAccountQuotaStatusText()?.visibility = View.GONE | ||
} | ||
} | ||
collectLatestLifecycleFlow(drawerViewModel.userQuota) { userQuota -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some changes in all these lines in the Detekt branch, I think just for the MaxLineLength
rule. Try to keep them in the new place for these lines so that we don't duplicate work
@Query(SELECT_QUOTA) | ||
fun getQuotaForAccountAsFlow( | ||
accountName: String | ||
): Flow<UserQuotaEntity> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why with the same SQL query you have a nullable result in the previous method but not here?
|
||
ocLocalUserDataSource.deleteQuotaForAccount(OC_ACCOUNT_NAME) | ||
val userQuota = ocLocalUserDataSource.getQuotaForAccountAsFlow(OC_ACCOUNT_NAME).first() | ||
assertEquals(userQuotaEntity.toModel(), userQuota) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertEquals(userQuotaEntity.toModel(), userQuota) | |
assertEquals(OC_USER_QUOTA, userQuota) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
} returns flowOf(listOf(userQuotaEntity)) | ||
|
||
val listOfUserQuotas = ocLocalUserDataSource.getAllUserQuotasAsFlow().first() | ||
assertEquals(listOf(userQuotaEntity.toModel()), listOfUserQuotas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertEquals(listOf(userQuotaEntity.toModel()), listOfUserQuotas) | |
assertEquals(listOf(OC_USER_QUOTA), listOfUserQuotas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as previous comment 😄
Related Issues
App: #4521
ReleaseNotesViewModel.kt
creating a newReleaseNote()
with String resources (if required)QA