Skip to content

Commit c46bc6c

Browse files
authored
fix(apps): consider protocol instead of feature flag for enabling apps interaction (WPB-21835) (#4428)
1 parent c2a1375 commit c46bc6c

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModel.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class GroupConversationDetailsViewModel @Inject constructor(
8080
private val isMLSEnabled: IsMLSEnabledUseCase,
8181
refreshUsersWithoutMetadata: RefreshUsersWithoutMetadataUseCase,
8282
private val isWireCellsEnabled: IsWireCellsEnabledUseCase,
83-
private val observeIsAppsAllowedForUsage: ObserveIsAppsAllowedForUsageUseCase,
83+
private val observeIsAppsAllowedForUsage: ObserveIsAppsAllowedForUsageUseCase
8484
) : GroupConversationParticipantsViewModel(savedStateHandle, observeConversationMembers, refreshUsersWithoutMetadata),
8585
ActionsManager<GroupConversationDetailsViewAction> by ActionsManagerImpl() {
8686

@@ -132,6 +132,10 @@ class GroupConversationDetailsViewModel @Inject constructor(
132132
val channelPermissionType = groupDetails.getChannelPermissionType()
133133
val channelAccessType = groupDetails.getChannelAccessType()
134134

135+
// todo: WPB-21835: ignoring feature flag, and based on protocol until there is finalized apps support.
136+
// isAppsUsageAllowed should be consider then.
137+
val isMLSConversation = groupDetails.conversation.protocol is Conversation.ProtocolInfo.MLS
138+
135139
_isFetchingInitialData.value = false
136140

137141
updateState(
@@ -146,8 +150,8 @@ class GroupConversationDetailsViewModel @Inject constructor(
146150
isUpdatingNameAllowed = canSelfPerformAdminTasks && !isSelfExternalMember,
147151
isUpdatingGuestAllowed = canSelfPerformAdminTasks && isSelfInTeamThatOwnsConversation,
148152
isUpdatingChannelAccessAllowed = canSelfPerformAdminTasks && isSelfInTeamThatOwnsConversation,
149-
isServicesAllowed = groupDetails.conversation.isServicesAllowed() && isAppsUsageAllowed,
150-
isUpdatingServicesAllowed = canSelfPerformAdminTasks && isAppsUsageAllowed,
153+
isServicesAllowed = groupDetails.conversation.isServicesAllowed() && !isMLSConversation,
154+
isUpdatingServicesAllowed = canSelfPerformAdminTasks && isSelfInTeamThatOwnsConversation && !isMLSConversation,
151155
isUpdatingReadReceiptAllowed = canSelfPerformAdminTasks && groupDetails.conversation.isTeamGroup(),
152156
isUpdatingSelfDeletingAllowed = canSelfPerformAdminTasks,
153157
mlsEnabled = isMLSEnabled(),

app/src/main/kotlin/com/wire/android/ui/home/newconversation/NewConversationViewModel.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class NewConversationViewModel @Inject constructor(
6666
private val getSelfUser: GetSelfUserUseCase,
6767
private val getDefaultProtocol: GetDefaultProtocolUseCase,
6868
private val isWireCellsFeatureEnabled: IsWireCellsEnabledUseCase,
69-
private val observeIsAppsAllowedForUsage: ObserveIsAppsAllowedForUsageUseCase
69+
private val observeIsAppsAllowedForUsage: ObserveIsAppsAllowedForUsageUseCase,
7070
) : ViewModel() {
7171

7272
var newGroupNameTextState: TextFieldState = TextFieldState()
@@ -96,9 +96,11 @@ class NewConversationViewModel @Inject constructor(
9696
viewModelScope.launch {
9797
observeIsAppsAllowedForUsage()
9898
.collectLatest { appsAllowed ->
99+
// todo: WPB-21835: ignoring feature flag, and based on protocol until there is finalized apps support.
100+
val isMLS = newGroupState.groupProtocol == CreateConversationParam.Protocol.MLS
99101
groupOptionsState = groupOptionsState.copy(
100-
isTeamAllowedToUseApps = appsAllowed,
101-
isAllowAppsEnabled = appsAllowed
102+
isTeamAllowedToUseApps = !isMLS,
103+
isAllowAppsEnabled = !isMLS
102104
)
103105
}
104106
}

app/src/test/kotlin/com/wire/android/ui/home/newconversation/NewConversationViewModelTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,15 @@ class NewConversationViewModelTest {
366366
}
367367

368368
@Test
369-
fun `given apps are not allowed, when initializing viewModel, then state should reflect that`() = runTest {
369+
fun `given apps are not allowed, when initializing, then state should ignore the feature flag and based on protocol`() = runTest {
370370
// Given
371371
val (_, viewModel) = NewConversationViewModelArrangement()
372372
.withGetSelfUser(isTeamMember = true)
373373
.withAppsAllowedResult(false)
374374
.arrange()
375375

376-
assertFalse(viewModel.groupOptionsState.isTeamAllowedToUseApps)
377-
assertFalse(viewModel.groupOptionsState.isAllowAppsEnabled)
376+
assertTrue(viewModel.groupOptionsState.isTeamAllowedToUseApps)
377+
assertTrue(viewModel.groupOptionsState.isAllowAppsEnabled)
378378
}
379379

380380
@Test

0 commit comments

Comments
 (0)