Skip to content

Commit bbb572f

Browse files
PM-30130: Remove the Archive Items feature flag
1 parent 193ec12 commit bbb572f

18 files changed

Lines changed: 14 additions & 270 deletions

File tree

app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/feature/search/SearchViewModel.kt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.os.Parcelable
44
import androidx.lifecycle.SavedStateHandle
55
import androidx.lifecycle.viewModelScope
66
import com.bitwarden.annotation.OmitFromCoverage
7-
import com.bitwarden.core.data.manager.model.FlagKey
87
import com.bitwarden.core.data.repository.model.DataState
98
import com.bitwarden.data.repository.util.baseIconUrl
109
import com.bitwarden.data.repository.util.baseWebSendUrl
@@ -30,7 +29,6 @@ import com.x8bit.bitwarden.data.autofill.accessibility.manager.AccessibilitySele
3029
import com.x8bit.bitwarden.data.autofill.manager.AutofillSelectionManager
3130
import com.x8bit.bitwarden.data.autofill.model.AutofillSelectionData
3231
import com.x8bit.bitwarden.data.autofill.util.login
33-
import com.x8bit.bitwarden.data.platform.manager.FeatureFlagManager
3432
import com.x8bit.bitwarden.data.platform.manager.PolicyManager
3533
import com.x8bit.bitwarden.data.platform.manager.SpecialCircumstanceManager
3634
import com.x8bit.bitwarden.data.platform.manager.clipboard.BitwardenClipboardManager
@@ -104,7 +102,6 @@ class SearchViewModel @Inject constructor(
104102
settingsRepo: SettingsRepository,
105103
snackbarRelayManager: SnackbarRelayManager<SnackbarRelay>,
106104
specialCircumstanceManager: SpecialCircumstanceManager,
107-
featureFlagManager: FeatureFlagManager,
108105
) : BaseViewModel<SearchState, SearchEvent, SearchAction>(
109106
// We load the state from the savedStateHandle for testing purposes.
110107
initialState = savedStateHandle[KEY_STATE]
@@ -140,7 +137,6 @@ class SearchViewModel @Inject constructor(
140137
hasMasterPassword = userState.activeAccount.hasMasterPassword,
141138
isPremium = userState.activeAccount.isPremium,
142139
restrictItemTypesPolicyOrgIds = persistentListOf(),
143-
isArchiveEnabled = featureFlagManager.getFeatureFlag(FlagKey.ArchiveItems),
144140
)
145141
},
146142
) {
@@ -180,12 +176,6 @@ class SearchViewModel @Inject constructor(
180176
.map { SearchAction.Internal.SnackbarDataReceived(it) }
181177
.onEach(::sendAction)
182178
.launchIn(viewModelScope)
183-
184-
featureFlagManager
185-
.getFeatureFlagFlow(FlagKey.ArchiveItems)
186-
.map { SearchAction.Internal.ArchiveItemsFlagUpdateReceive(it) }
187-
.onEach(::sendAction)
188-
.launchIn(viewModelScope)
189179
}
190180

191181
override fun handleAction(action: SearchAction) {
@@ -640,10 +630,6 @@ class SearchViewModel @Inject constructor(
640630
handleDecryptCipherErrorReceive(action)
641631
}
642632

643-
is SearchAction.Internal.ArchiveItemsFlagUpdateReceive -> {
644-
handleArchiveItemsFlagUpdateReceive(action)
645-
}
646-
647633
is SearchAction.Internal.ArchiveCipherReceive -> handleArchiveCipherReceive(action)
648634
is SearchAction.Internal.UnarchiveCipherReceive -> handleUnarchiveCipherReceive(action)
649635
}
@@ -663,12 +649,6 @@ class SearchViewModel @Inject constructor(
663649
}
664650
}
665651

666-
private fun handleArchiveItemsFlagUpdateReceive(
667-
action: SearchAction.Internal.ArchiveItemsFlagUpdateReceive,
668-
) {
669-
mutableStateFlow.update { it.copy(isArchiveEnabled = action.isEnabled) }
670-
}
671-
672652
private fun handleArchiveCipherReceive(action: SearchAction.Internal.ArchiveCipherReceive) {
673653
when (val result = action.result) {
674654
is ArchiveCipherResult.Error -> {
@@ -1017,7 +997,6 @@ class SearchViewModel @Inject constructor(
1017997
isIconLoadingDisabled = state.isIconLoadingDisabled,
1018998
isAutofill = state.isAutofill,
1019999
isPremiumUser = state.isPremium,
1020-
isArchiveEnabled = state.isArchiveEnabled,
10211000
)
10221001
}
10231002

@@ -1084,7 +1063,6 @@ data class SearchState(
10841063
val hasMasterPassword: Boolean,
10851064
val isPremium: Boolean,
10861065
val restrictItemTypesPolicyOrgIds: ImmutableList<String>,
1087-
val isArchiveEnabled: Boolean,
10881066
) : Parcelable {
10891067

10901068
/**
@@ -1537,13 +1515,6 @@ sealed class SearchAction {
15371515
data class DecryptCipherErrorReceive(
15381516
val error: Throwable?,
15391517
) : Internal()
1540-
1541-
/**
1542-
* Indicates that the Archive Items flag has been updated.
1543-
*/
1544-
data class ArchiveItemsFlagUpdateReceive(
1545-
val isEnabled: Boolean,
1546-
) : Internal()
15471518
}
15481519
}
15491520

app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchTypeDataExtensions.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ fun List<CipherListView>.toViewState(
186186
isIconLoadingDisabled: Boolean,
187187
isAutofill: Boolean,
188188
isPremiumUser: Boolean,
189-
isArchiveEnabled: Boolean,
190189
): SearchState.ViewState =
191190
when {
192191
searchTerm.isEmpty() -> SearchState.ViewState.Empty(message = null)
@@ -198,7 +197,6 @@ fun List<CipherListView>.toViewState(
198197
isIconLoadingDisabled = isIconLoadingDisabled,
199198
isAutofill = isAutofill,
200199
isPremiumUser = isPremiumUser,
201-
isArchiveEnabled = isArchiveEnabled,
202200
)
203201
.sortAlphabetically(),
204202
)
@@ -211,14 +209,12 @@ fun List<CipherListView>.toViewState(
211209
}
212210
}
213211

214-
@Suppress("LongParameterList")
215212
private fun List<CipherListView>.toDisplayItemList(
216213
baseIconUrl: String,
217214
hasMasterPassword: Boolean,
218215
isIconLoadingDisabled: Boolean,
219216
isAutofill: Boolean,
220217
isPremiumUser: Boolean,
221-
isArchiveEnabled: Boolean,
222218
): List<SearchState.DisplayItem> =
223219
this.map {
224220
it.toDisplayItem(
@@ -227,18 +223,15 @@ private fun List<CipherListView>.toDisplayItemList(
227223
isIconLoadingDisabled = isIconLoadingDisabled,
228224
isAutofill = isAutofill,
229225
isPremiumUser = isPremiumUser,
230-
isArchiveEnabled = isArchiveEnabled,
231226
)
232227
}
233228

234-
@Suppress("LongParameterList")
235229
private fun CipherListView.toDisplayItem(
236230
baseIconUrl: String,
237231
hasMasterPassword: Boolean,
238232
isIconLoadingDisabled: Boolean,
239233
isAutofill: Boolean,
240234
isPremiumUser: Boolean,
241-
isArchiveEnabled: Boolean,
242235
): SearchState.DisplayItem =
243236
SearchState.DisplayItem(
244237
id = id.orEmpty(),
@@ -254,7 +247,6 @@ private fun CipherListView.toDisplayItem(
254247
overflowOptions = toOverflowActions(
255248
hasMasterPassword = hasMasterPassword,
256249
isPremiumUser = isPremiumUser,
257-
isArchiveEnabled = isArchiveEnabled,
258250
),
259251
overflowTestTag = "CipherOptionsButton",
260252
totpCode = login?.totp,

app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditViewModel.kt

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import androidx.credentials.CreatePublicKeyCredentialRequest
55
import androidx.credentials.provider.CallingAppInfo
66
import androidx.lifecycle.SavedStateHandle
77
import androidx.lifecycle.viewModelScope
8-
import com.bitwarden.core.data.manager.model.FlagKey
98
import com.bitwarden.core.data.manager.toast.ToastManager
109
import com.bitwarden.core.data.repository.model.DataState
1110
import com.bitwarden.core.data.repository.util.takeUntilLoaded
@@ -34,7 +33,6 @@ import com.x8bit.bitwarden.data.credentials.manager.BitwardenCredentialManager
3433
import com.x8bit.bitwarden.data.credentials.model.CreateCredentialRequest
3534
import com.x8bit.bitwarden.data.credentials.model.Fido2RegisterCredentialResult
3635
import com.x8bit.bitwarden.data.credentials.model.UserVerificationRequirement
37-
import com.x8bit.bitwarden.data.platform.manager.FeatureFlagManager
3836
import com.x8bit.bitwarden.data.platform.manager.FirstTimeActionManager
3937
import com.x8bit.bitwarden.data.platform.manager.PolicyManager
4038
import com.x8bit.bitwarden.data.platform.manager.SpecialCircumstanceManager
@@ -119,7 +117,6 @@ private const val KEY_STATE = "state"
119117
@Suppress("TooManyFunctions", "LargeClass", "LongParameterList", "LongMethod")
120118
class VaultAddEditViewModel @Inject constructor(
121119
savedStateHandle: SavedStateHandle,
122-
featureFlagManager: FeatureFlagManager,
123120
generatorRepository: GeneratorRepository,
124121
private val snackbarRelayManager: SnackbarRelayManager<SnackbarRelay>,
125122
private val toastManager: ToastManager,
@@ -177,7 +174,6 @@ class VaultAddEditViewModel @Inject constructor(
177174
}
178175

179176
VaultAddEditState(
180-
isArchiveEnabled = featureFlagManager.getFeatureFlag(FlagKey.ArchiveItems),
181177
vaultAddEditType = vaultAddEditType,
182178
cipherType = vaultCipherType,
183179
viewState = when (vaultAddEditType) {
@@ -273,12 +269,6 @@ class VaultAddEditViewModel @Inject constructor(
273269
.onEach(::sendAction)
274270
.launchIn(viewModelScope)
275271

276-
featureFlagManager
277-
.getFeatureFlagFlow(FlagKey.ArchiveItems)
278-
.map { VaultAddEditAction.Internal.ArchiveItemsFlagUpdateReceive(it) }
279-
.onEach(::sendAction)
280-
.launchIn(viewModelScope)
281-
282272
snackbarRelayManager
283273
.getSnackbarDataFlow(SnackbarRelay.CIPHER_MOVED_TO_ORGANIZATION)
284274
.map { VaultAddEditAction.Internal.SnackbarDataReceived(it) }
@@ -1649,10 +1639,6 @@ class VaultAddEditViewModel @Inject constructor(
16491639
handleUnarchiveCipherReceive(action)
16501640
}
16511641

1652-
is VaultAddEditAction.Internal.ArchiveItemsFlagUpdateReceive -> {
1653-
handleArchiveItemsFlagUpdateReceive(action)
1654-
}
1655-
16561642
is VaultAddEditAction.Internal.DeleteCipherReceive -> handleDeleteCipherReceive(action)
16571643
is VaultAddEditAction.Internal.TotpCodeReceive -> handleVaultTotpCodeReceive(action)
16581644
is VaultAddEditAction.Internal.VaultDataReceive -> handleVaultDataReceive(action)
@@ -1864,12 +1850,6 @@ class VaultAddEditViewModel @Inject constructor(
18641850
}
18651851
}
18661852

1867-
private fun handleArchiveItemsFlagUpdateReceive(
1868-
action: VaultAddEditAction.Internal.ArchiveItemsFlagUpdateReceive,
1869-
) {
1870-
mutableStateFlow.update { it.copy(isArchiveEnabled = action.isEnabled) }
1871-
}
1872-
18731853
private fun handleDeleteCipherReceive(action: VaultAddEditAction.Internal.DeleteCipherReceive) {
18741854
when (val result = action.result) {
18751855
is DeleteCipherResult.Error -> {
@@ -2427,7 +2407,6 @@ data class VaultAddEditState(
24272407
val createCredentialRequest: CreateCredentialRequest? = null,
24282408
val defaultUriMatchType: UriMatchType,
24292409
private val shouldShowCoachMarkTour: Boolean,
2430-
private val isArchiveEnabled: Boolean,
24312410
) : Parcelable {
24322411

24332412
/**
@@ -2484,8 +2463,7 @@ data class VaultAddEditState(
24842463
* Helper to determine if the UI should display the archive button.
24852464
*/
24862465
val displayArchiveButton: Boolean
2487-
get() = isArchiveEnabled &&
2488-
isEditItemMode &&
2466+
get() = isEditItemMode &&
24892467
(viewState as? ViewState.Content)
24902468
?.common
24912469
?.originalCipher
@@ -2495,8 +2473,7 @@ data class VaultAddEditState(
24952473
* Helper to determine if the UI should display the unarchive button.
24962474
*/
24972475
val displayUnarchiveButton: Boolean
2498-
get() = isArchiveEnabled &&
2499-
isEditItemMode &&
2476+
get() = isEditItemMode &&
25002477
(viewState as? ViewState.Content)
25012478
?.common
25022479
?.originalCipher
@@ -3834,12 +3811,5 @@ sealed class VaultAddEditAction {
38343811
data class AvailableFoldersReceive(
38353812
val folderData: DataState<List<FolderView>>,
38363813
) : Internal()
3837-
3838-
/**
3839-
* Indicates that the Archive Items flag has been updated.
3840-
*/
3841-
data class ArchiveItemsFlagUpdateReceive(
3842-
val isEnabled: Boolean,
3843-
) : Internal()
38443814
}
38453815
}

app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/item/VaultItemViewModel.kt

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.net.Uri
44
import android.os.Parcelable
55
import androidx.lifecycle.SavedStateHandle
66
import androidx.lifecycle.viewModelScope
7-
import com.bitwarden.core.data.manager.model.FlagKey
87
import com.bitwarden.core.data.repository.model.DataState
98
import com.bitwarden.core.data.repository.util.combineDataStates
109
import com.bitwarden.core.data.repository.util.mapNullable
@@ -27,7 +26,6 @@ import com.bitwarden.vault.CipherView
2726
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
2827
import com.x8bit.bitwarden.data.auth.repository.model.BreachCountResult
2928
import com.x8bit.bitwarden.data.auth.repository.model.UserState
30-
import com.x8bit.bitwarden.data.platform.manager.FeatureFlagManager
3129
import com.x8bit.bitwarden.data.platform.manager.clipboard.BitwardenClipboardManager
3230
import com.x8bit.bitwarden.data.platform.manager.event.OrganizationEventManager
3331
import com.x8bit.bitwarden.data.platform.manager.model.OrganizationEvent
@@ -81,7 +79,6 @@ class VaultItemViewModel @Inject constructor(
8179
private val environmentRepository: EnvironmentRepository,
8280
private val settingsRepository: SettingsRepository,
8381
private val snackbarRelayManager: SnackbarRelayManager<SnackbarRelay>,
84-
featureFlagManager: FeatureFlagManager,
8582
) : BaseViewModel<VaultItemState, VaultItemEvent, VaultItemAction>(
8683
// We load the state from the savedStateHandle for testing purposes.
8784
initialState = savedStateHandle[KEY_STATE] ?: run {
@@ -94,7 +91,6 @@ class VaultItemViewModel @Inject constructor(
9491
baseIconUrl = environmentRepository.environment.environmentUrlData.baseIconUrl,
9592
isIconLoadingDisabled = settingsRepository.isIconLoadingDisabled,
9693
hasPremium = authRepository.userStateFlow.value?.activeAccount?.isPremium == true,
97-
isArchiveEnabled = featureFlagManager.getFeatureFlag(FlagKey.ArchiveItems),
9894
)
9995
},
10096
) {
@@ -231,12 +227,6 @@ class VaultItemViewModel @Inject constructor(
231227
.map { VaultItemAction.Internal.SnackbarDataReceived(it) }
232228
.onEach(::sendAction)
233229
.launchIn(viewModelScope)
234-
235-
featureFlagManager
236-
.getFeatureFlagFlow(FlagKey.ArchiveItems)
237-
.map { VaultItemAction.Internal.ArchiveItemsFlagUpdateReceive(it) }
238-
.onEach(::sendAction)
239-
.launchIn(viewModelScope)
240230
}
241231

242232
override fun handleAction(action: VaultItemAction) {
@@ -1040,10 +1030,6 @@ class VaultItemViewModel @Inject constructor(
10401030
handleIsIconLoadingDisabledUpdateReceive(action)
10411031
}
10421032

1043-
is VaultItemAction.Internal.ArchiveItemsFlagUpdateReceive -> {
1044-
handleArchiveItemsFlagUpdateReceive(action)
1045-
}
1046-
10471033
is VaultItemAction.Internal.ArchiveCipherReceive -> handleArchiveCipherReceive(action)
10481034
is VaultItemAction.Internal.UnarchiveCipherReceive -> {
10491035
handleUnarchiveCipherReceive(action)
@@ -1282,12 +1268,6 @@ class VaultItemViewModel @Inject constructor(
12821268
mutableStateFlow.update { it.copy(isIconLoadingDisabled = action.isDisabled) }
12831269
}
12841270

1285-
private fun handleArchiveItemsFlagUpdateReceive(
1286-
action: VaultItemAction.Internal.ArchiveItemsFlagUpdateReceive,
1287-
) {
1288-
mutableStateFlow.update { it.copy(isArchiveEnabled = action.isEnabled) }
1289-
}
1290-
12911271
private fun handleArchiveCipherReceive(action: VaultItemAction.Internal.ArchiveCipherReceive) {
12921272
when (val result = action.result) {
12931273
is ArchiveCipherResult.Error -> {
@@ -1426,7 +1406,6 @@ data class VaultItemState(
14261406
val dialog: DialogState?,
14271407
val baseIconUrl: String,
14281408
val isIconLoadingDisabled: Boolean,
1429-
val isArchiveEnabled: Boolean,
14301409
val hasPremium: Boolean,
14311410
) : Parcelable {
14321411

@@ -1493,21 +1472,19 @@ data class VaultItemState(
14931472
* Helper to determine if the UI should display the archive button.
14941473
*/
14951474
val displayArchiveButton: Boolean
1496-
get() = isArchiveEnabled &&
1497-
viewState.asContentOrNull()
1498-
?.common
1499-
?.currentCipher
1500-
?.let { it.archivedDate == null && it.deletedDate == null } == true
1475+
get() = viewState.asContentOrNull()
1476+
?.common
1477+
?.currentCipher
1478+
?.let { it.archivedDate == null && it.deletedDate == null } == true
15011479

15021480
/**
15031481
* Helper to determine if the UI should display the unarchive button.
15041482
*/
15051483
val displayUnarchiveButton: Boolean
1506-
get() = isArchiveEnabled &&
1507-
viewState.asContentOrNull()
1508-
?.common
1509-
?.currentCipher
1510-
?.let { it.archivedDate != null && it.deletedDate == null } == true
1484+
get() = viewState.asContentOrNull()
1485+
?.common
1486+
?.currentCipher
1487+
?.let { it.archivedDate != null && it.deletedDate == null } == true
15111488

15121489
val canAssignToCollections: Boolean
15131490
get() = viewState.asContentOrNull()
@@ -2334,13 +2311,6 @@ sealed class VaultItemAction {
23342311
val data: BitwardenSnackbarData,
23352312
) : Internal()
23362313

2337-
/**
2338-
* Indicates that the Archive Items flag has been updated.
2339-
*/
2340-
data class ArchiveItemsFlagUpdateReceive(
2341-
val isEnabled: Boolean,
2342-
) : Internal()
2343-
23442314
/**
23452315
* Indicates that the archive cipher result has been received.
23462316
*/

0 commit comments

Comments
 (0)