Skip to content

Commit 1632a53

Browse files
PM-30130: Remove the Archive Items feature flag
1 parent cbc9c29 commit 1632a53

29 files changed

Lines changed: 32 additions & 406 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
/**
@@ -1517,13 +1495,6 @@ sealed class SearchAction {
15171495
data class DecryptCipherErrorReceive(
15181496
val error: Throwable?,
15191497
) : Internal()
1520-
1521-
/**
1522-
* Indicates that the Archive Items flag has been updated.
1523-
*/
1524-
data class ArchiveItemsFlagUpdateReceive(
1525-
val isEnabled: Boolean,
1526-
) : Internal()
15271498
}
15281499
}
15291500

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
@@ -164,7 +164,6 @@ fun List<CipherListView>.toViewState(
164164
isIconLoadingDisabled: Boolean,
165165
isAutofill: Boolean,
166166
isPremiumUser: Boolean,
167-
isArchiveEnabled: Boolean,
168167
): SearchState.ViewState =
169168
when {
170169
searchTerm.isEmpty() -> SearchState.ViewState.Empty(message = null)
@@ -176,7 +175,6 @@ fun List<CipherListView>.toViewState(
176175
isIconLoadingDisabled = isIconLoadingDisabled,
177176
isAutofill = isAutofill,
178177
isPremiumUser = isPremiumUser,
179-
isArchiveEnabled = isArchiveEnabled,
180178
),
181179
)
182180
}
@@ -188,14 +186,12 @@ fun List<CipherListView>.toViewState(
188186
}
189187
}
190188

191-
@Suppress("LongParameterList")
192189
private fun List<CipherListView>.toDisplayItemList(
193190
baseIconUrl: String,
194191
hasMasterPassword: Boolean,
195192
isIconLoadingDisabled: Boolean,
196193
isAutofill: Boolean,
197194
isPremiumUser: Boolean,
198-
isArchiveEnabled: Boolean,
199195
): ImmutableList<SearchState.DisplayItem> =
200196
this
201197
.map {
@@ -205,20 +201,17 @@ private fun List<CipherListView>.toDisplayItemList(
205201
isIconLoadingDisabled = isIconLoadingDisabled,
206202
isAutofill = isAutofill,
207203
isPremiumUser = isPremiumUser,
208-
isArchiveEnabled = isArchiveEnabled,
209204
)
210205
}
211206
.sortAlphabetically()
212207
.toImmutableList()
213208

214-
@Suppress("LongParameterList")
215209
private fun CipherListView.toDisplayItem(
216210
baseIconUrl: String,
217211
hasMasterPassword: Boolean,
218212
isIconLoadingDisabled: Boolean,
219213
isAutofill: Boolean,
220214
isPremiumUser: Boolean,
221-
isArchiveEnabled: Boolean,
222215
): SearchState.DisplayItem =
223216
SearchState.DisplayItem(
224217
id = id.orEmpty(),
@@ -234,7 +227,6 @@ private fun CipherListView.toDisplayItem(
234227
overflowOptions = toOverflowActions(
235228
hasMasterPassword = hasMasterPassword,
236229
isPremiumUser = isPremiumUser,
237-
isArchiveEnabled = isArchiveEnabled,
238230
),
239231
overflowTestTag = "CipherOptionsButton",
240232
totpCode = login?.totp,

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

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ class VaultAddEditViewModel @Inject constructor(
182182
}
183183

184184
VaultAddEditState(
185-
isArchiveEnabled = featureFlagManager.getFeatureFlag(FlagKey.ArchiveItems),
186185
isCardScannerEnabled = featureFlagManager.getFeatureFlag(FlagKey.CardScanner),
187186
vaultAddEditType = vaultAddEditType,
188187
cipherType = vaultCipherType,
@@ -279,12 +278,6 @@ class VaultAddEditViewModel @Inject constructor(
279278
.onEach(::sendAction)
280279
.launchIn(viewModelScope)
281280

282-
featureFlagManager
283-
.getFeatureFlagFlow(FlagKey.ArchiveItems)
284-
.map { VaultAddEditAction.Internal.ArchiveItemsFlagUpdateReceive(it) }
285-
.onEach(::sendAction)
286-
.launchIn(viewModelScope)
287-
288281
featureFlagManager
289282
.getFeatureFlagFlow(FlagKey.CardScanner)
290283
.map { VaultAddEditAction.Internal.CardScannerFlagUpdateReceive(it) }
@@ -1697,10 +1690,6 @@ class VaultAddEditViewModel @Inject constructor(
16971690
handleUnarchiveCipherReceive(action)
16981691
}
16991692

1700-
is VaultAddEditAction.Internal.ArchiveItemsFlagUpdateReceive -> {
1701-
handleArchiveItemsFlagUpdateReceive(action)
1702-
}
1703-
17041693
is VaultAddEditAction.Internal.CardScannerFlagUpdateReceive -> {
17051694
handleCardScannerFlagUpdateReceive(action)
17061695
}
@@ -1920,12 +1909,6 @@ class VaultAddEditViewModel @Inject constructor(
19201909
}
19211910
}
19221911

1923-
private fun handleArchiveItemsFlagUpdateReceive(
1924-
action: VaultAddEditAction.Internal.ArchiveItemsFlagUpdateReceive,
1925-
) {
1926-
mutableStateFlow.update { it.copy(isArchiveEnabled = action.isEnabled) }
1927-
}
1928-
19291912
private fun handleCardScannerFlagUpdateReceive(
19301913
action: VaultAddEditAction.Internal.CardScannerFlagUpdateReceive,
19311914
) {
@@ -2535,7 +2518,6 @@ data class VaultAddEditState(
25352518
val createCredentialRequest: CreateCredentialRequest? = null,
25362519
val defaultUriMatchType: UriMatchType,
25372520
private val shouldShowCoachMarkTour: Boolean,
2538-
private val isArchiveEnabled: Boolean,
25392521
val isCardScannerEnabled: Boolean,
25402522
) : Parcelable {
25412523

@@ -2593,8 +2575,7 @@ data class VaultAddEditState(
25932575
* Helper to determine if the UI should display the archive button.
25942576
*/
25952577
val displayArchiveButton: Boolean
2596-
get() = isArchiveEnabled &&
2597-
isEditItemMode &&
2578+
get() = isEditItemMode &&
25982579
(viewState as? ViewState.Content)
25992580
?.common
26002581
?.originalCipher
@@ -2604,8 +2585,7 @@ data class VaultAddEditState(
26042585
* Helper to determine if the UI should display the unarchive button.
26052586
*/
26062587
val displayUnarchiveButton: Boolean
2607-
get() = isArchiveEnabled &&
2608-
isEditItemMode &&
2588+
get() = isEditItemMode &&
26092589
(viewState as? ViewState.Content)
26102590
?.common
26112591
?.originalCipher
@@ -3978,13 +3958,6 @@ sealed class VaultAddEditAction {
39783958
val folderData: DataState<List<FolderView>>,
39793959
) : Internal()
39803960

3981-
/**
3982-
* Indicates that the Archive Items flag has been updated.
3983-
*/
3984-
data class ArchiveItemsFlagUpdateReceive(
3985-
val isEnabled: Boolean,
3986-
) : Internal()
3987-
39883961
/**
39893962
* Indicates that the Card Scanner flag has been updated.
39903963
*/

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
@@ -82,7 +80,6 @@ class VaultItemViewModel @Inject constructor(
8280
private val environmentRepository: EnvironmentRepository,
8381
private val settingsRepository: SettingsRepository,
8482
private val snackbarRelayManager: SnackbarRelayManager<SnackbarRelay>,
85-
featureFlagManager: FeatureFlagManager,
8683
) : BaseViewModel<VaultItemState, VaultItemEvent, VaultItemAction>(
8784
// We load the state from the savedStateHandle for testing purposes.
8885
initialState = savedStateHandle[KEY_STATE] ?: run {
@@ -95,7 +92,6 @@ class VaultItemViewModel @Inject constructor(
9592
baseIconUrl = environmentRepository.environment.environmentUrlData.baseIconUrl,
9693
isIconLoadingDisabled = settingsRepository.isIconLoadingDisabled,
9794
hasPremium = authRepository.userStateFlow.value?.activeAccount?.isPremium == true,
98-
isArchiveEnabled = featureFlagManager.getFeatureFlag(FlagKey.ArchiveItems),
9995
)
10096
},
10197
) {
@@ -232,12 +228,6 @@ class VaultItemViewModel @Inject constructor(
232228
.map { VaultItemAction.Internal.SnackbarDataReceived(it) }
233229
.onEach(::sendAction)
234230
.launchIn(viewModelScope)
235-
236-
featureFlagManager
237-
.getFeatureFlagFlow(FlagKey.ArchiveItems)
238-
.map { VaultItemAction.Internal.ArchiveItemsFlagUpdateReceive(it) }
239-
.onEach(::sendAction)
240-
.launchIn(viewModelScope)
241231
}
242232

243233
override fun handleAction(action: VaultItemAction) {
@@ -1063,10 +1053,6 @@ class VaultItemViewModel @Inject constructor(
10631053
handleIsIconLoadingDisabledUpdateReceive(action)
10641054
}
10651055

1066-
is VaultItemAction.Internal.ArchiveItemsFlagUpdateReceive -> {
1067-
handleArchiveItemsFlagUpdateReceive(action)
1068-
}
1069-
10701056
is VaultItemAction.Internal.ArchiveCipherReceive -> handleArchiveCipherReceive(action)
10711057
is VaultItemAction.Internal.UnarchiveCipherReceive -> {
10721058
handleUnarchiveCipherReceive(action)
@@ -1302,12 +1288,6 @@ class VaultItemViewModel @Inject constructor(
13021288
mutableStateFlow.update { it.copy(isIconLoadingDisabled = action.isDisabled) }
13031289
}
13041290

1305-
private fun handleArchiveItemsFlagUpdateReceive(
1306-
action: VaultItemAction.Internal.ArchiveItemsFlagUpdateReceive,
1307-
) {
1308-
mutableStateFlow.update { it.copy(isArchiveEnabled = action.isEnabled) }
1309-
}
1310-
13111291
private fun handleArchiveCipherReceive(action: VaultItemAction.Internal.ArchiveCipherReceive) {
13121292
when (val result = action.result) {
13131293
is ArchiveCipherResult.Error -> {
@@ -1446,7 +1426,6 @@ data class VaultItemState(
14461426
val dialog: DialogState?,
14471427
val baseIconUrl: String,
14481428
val isIconLoadingDisabled: Boolean,
1449-
val isArchiveEnabled: Boolean,
14501429
val hasPremium: Boolean,
14511430
) : Parcelable {
14521431

@@ -1513,21 +1492,19 @@ data class VaultItemState(
15131492
* Helper to determine if the UI should display the archive button.
15141493
*/
15151494
val displayArchiveButton: Boolean
1516-
get() = isArchiveEnabled &&
1517-
viewState.asContentOrNull()
1518-
?.common
1519-
?.currentCipher
1520-
?.isActive == true
1495+
get() = viewState.asContentOrNull()
1496+
?.common
1497+
?.currentCipher
1498+
?.isActive == true
15211499

15221500
/**
15231501
* Helper to determine if the UI should display the unarchive button.
15241502
*/
15251503
val displayUnarchiveButton: Boolean
1526-
get() = isArchiveEnabled &&
1527-
viewState.asContentOrNull()
1528-
?.common
1529-
?.currentCipher
1530-
?.let { it.archivedDate != null && it.deletedDate == null } == true
1504+
get() = viewState.asContentOrNull()
1505+
?.common
1506+
?.currentCipher
1507+
?.let { it.archivedDate != null && it.deletedDate == null } == true
15311508

15321509
val canAssignToCollections: Boolean
15331510
get() = viewState.asContentOrNull()
@@ -2372,13 +2349,6 @@ sealed class VaultItemAction {
23722349
val data: BitwardenSnackbarData,
23732350
) : Internal()
23742351

2375-
/**
2376-
* Indicates that the Archive Items flag has been updated.
2377-
*/
2378-
data class ArchiveItemsFlagUpdateReceive(
2379-
val isEnabled: Boolean,
2380-
) : Internal()
2381-
23822352
/**
23832353
* Indicates that the archive cipher result has been received.
23842354
*/

0 commit comments

Comments
 (0)