BIT-1418: Add premium feature restriction notice to attachments (#787)

This commit is contained in:
David Perez
2024-01-25 14:23:51 -06:00
committed by Álison Fernandes
parent 064b767b56
commit 05bdf5a25e
2 changed files with 33 additions and 18 deletions

View File

@@ -47,12 +47,19 @@ class AttachmentsViewModel @Inject constructor(
) : BaseViewModel<AttachmentsState, AttachmentsEvent, AttachmentsAction>(
// We load the state from the savedStateHandle for testing purposes.
initialState = savedStateHandle[KEY_STATE]
?: AttachmentsState(
cipherId = AttachmentsArgs(savedStateHandle).cipherId,
viewState = AttachmentsState.ViewState.Loading,
dialogState = null,
isPremiumUser = authRepo.userStateFlow.value?.activeAccount?.isPremium == true,
),
?: run {
val isPremiumUser = authRepo.userStateFlow.value?.activeAccount?.isPremium == true
AttachmentsState(
cipherId = AttachmentsArgs(savedStateHandle).cipherId,
viewState = AttachmentsState.ViewState.Loading,
dialogState = AttachmentsState.DialogState.Error(
title = null,
message = R.string.premium_required.asText(),
)
.takeUnless { isPremiumUser },
isPremiumUser = isPremiumUser,
)
},
) {
init {
vaultRepo