Skip to content

Commit bd44005

Browse files
authored
feat: show proper error message if user is not allowed to create a conversation(WPB-16977) (#3985)
1 parent 24a77c3 commit bd44005

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

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

Lines changed: 11 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 globalDataStore: GlobalDataStore,
69-
) : ViewModel() {
69+
) : ViewModel() {
7070

7171
var newGroupNameTextState: TextFieldState = TextFieldState()
7272
var newGroupState: GroupMetadataState by mutableStateOf(
@@ -320,16 +320,24 @@ class NewConversationViewModel @Inject constructor(
320320
result.conversation.id
321321
}
322322

323+
ConversationCreationResult.Forbidden -> {
324+
appLogger.d("Can't create conversation due to Insufficient permissions")
325+
groupOptionsState = groupOptionsState.copy(isLoading = false)
326+
newGroupState = newGroupState.copy(isLoading = false)
327+
createGroupState = createGroupState.copy(error = CreateGroupState.Error.Forbidden)
328+
null
329+
}
330+
323331
ConversationCreationResult.SyncFailure -> {
324-
appLogger.d("Can't create group due to SyncFailure")
332+
appLogger.d("Can't create conversation due to SyncFailure")
325333
groupOptionsState = groupOptionsState.copy(isLoading = false)
326334
newGroupState = newGroupState.copy(isLoading = false)
327335
createGroupState = createGroupState.copy(error = CreateGroupState.Error.LackingConnection)
328336
null
329337
}
330338

331339
is ConversationCreationResult.UnknownFailure -> {
332-
appLogger.w("Error while creating a group ${result.cause}")
340+
appLogger.w("Error while creating a conversation ${result.cause}")
333341
groupOptionsState = groupOptionsState.copy(isLoading = false)
334342
newGroupState = newGroupState.copy(isLoading = false)
335343
createGroupState = createGroupState.copy(error = CreateGroupState.Error.Unknown)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ fun CreateGroupErrorDialog(
5757
linkText = stringResource(id = R.string.label_learn_more),
5858
linkUrl = stringResource(id = R.string.url_message_details_offline_backends_learn_more)
5959
)
60+
is CreateGroupState.Error.Forbidden -> DialogErrorStrings(
61+
title = stringResource(R.string.conversation_can_not_be_created_title),
62+
message = stringResource(R.string.create_channel_error_forbidden_message),
63+
) to null
6064
}
6165

6266
WireDialog(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ data class CreateGroupState(
2222
) {
2323
sealed interface Error {
2424
data object Unknown : Error
25+
data object Forbidden : Error
2526
data object LackingConnection : Error
2627
data class ConflictedBackends(val domains: List<String>) : Error
2728

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@
560560
<string name="regular_group_name_exceeded_limit_error">Group name should not exceed 64 characters</string>
561561
<string name="channel_name_exceeded_limit_error">Channel name should not exceed 64 characters</string>
562562
<string name="conversation_can_not_be_created_title">Conversation can\'t be created</string>
563+
<string name="create_channel_error_forbidden_message">Feature is not available, please check with your team admin</string>
563564
<string name="conversation_can_not_be_created_federation_conflict_description">People from backends %1$s and %2$s can\'t join the same conversation.\n\nTo create the conversation, remove affected participants.</string>
564565
<string name="conversation_can_not_be_created_edit_participant_list">Edit Participants List</string>
565566
<string name="conversation_can_not_be_created_discard_creation">Discard Conversation Creation</string>

0 commit comments

Comments
 (0)