Skip to content

Commit 090dd5f

Browse files
Garzastmspzz
andauthored
fix: before revoking guest users, wait for removing guest link [AR-3310] (#1694)
* fix: before revoking guest users, wait for removing guest link * moved logic to use case --------- Co-authored-by: Tommaso Piazza <196761+tmspzz@users.noreply.github.com>
1 parent be6540e commit 090dd5f

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fun EditGuestAccessScreen(
165165
}
166166
if (editGuestAccessState.shouldShowRevokeLinkConfirmationDialog) {
167167
RevokeGuestConfirmationDialog(
168-
onConfirm = ::onRevokeDialogConfirm, onDialogDismiss = ::onRevokeDialogDismiss
168+
onConfirm = ::removeGuestLink, onDialogDismiss = ::onRevokeDialogDismiss
169169
)
170170
}
171171
if (editGuestAccessState.isFailedToGenerateGuestRoomLink) {

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,12 @@ class EditGuestAccessViewModel @Inject constructor(
156156
guestAllowed = shouldEnableGuestAccess,
157157
servicesAllowed = editGuestAccessState.isServicesAccessAllowed,
158158
nonTeamMembersAllowed = shouldEnableGuestAccess // Guest access controls non-team member access
159-
)
159+
)
160160
val newAccess = Conversation
161161
.accessFor(shouldEnableGuestAccess)
162162

163163
viewModelScope.launch {
164164
withContext(dispatcher.io()) {
165-
if (!shouldEnableGuestAccess) {
166-
removeGuestLink()
167-
}
168165
updateConversationAccessRole(
169166
conversationId = conversationId,
170167
accessRoles = newAccessRoles,
@@ -223,13 +220,9 @@ class EditGuestAccessViewModel @Inject constructor(
223220
editGuestAccessState = editGuestAccessState.copy(shouldShowRevokeLinkConfirmationDialog = false)
224221
}
225222

226-
fun onRevokeDialogConfirm() {
227-
removeGuestLink()
228-
}
229-
230-
private fun removeGuestLink() {
231-
updateState(editGuestAccessState.copy(shouldShowRevokeLinkConfirmationDialog = false, isRevokingLink = true))
223+
fun removeGuestLink() {
232224
viewModelScope.launch {
225+
updateState(editGuestAccessState.copy(shouldShowRevokeLinkConfirmationDialog = false, isRevokingLink = true))
233226
revokeGuestRoomLink(conversationId).also {
234227
if (it is RevokeGuestRoomLinkResult.Failure) {
235228
updateState(editGuestAccessState.copy(isFailedToRevokeGuestRoomLink = true))

app/src/test/kotlin/com/wire/android/ui/home/conversations/details/editguestaccess/EditGuestAccessViewModelTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class EditGuestAccessViewModelTest {
190190
revokeGuestRoomLink(any())
191191
} returns RevokeGuestRoomLinkResult.Success
192192

193-
editGuestAccessViewModel.onRevokeDialogConfirm()
193+
editGuestAccessViewModel.removeGuestLink()
194194

195195
coVerify(exactly = 1) {
196196
revokeGuestRoomLink(any())
@@ -204,7 +204,7 @@ class EditGuestAccessViewModelTest {
204204
revokeGuestRoomLink(any())
205205
} returns RevokeGuestRoomLinkResult.Failure(CoreFailure.MissingClientRegistration)
206206

207-
editGuestAccessViewModel.onRevokeDialogConfirm()
207+
editGuestAccessViewModel.removeGuestLink()
208208

209209
coVerify(exactly = 1) {
210210
revokeGuestRoomLink(any())

0 commit comments

Comments
 (0)