Skip to content

Commit

Permalink
Display proper error when call link deletion fails due to call link b…
Browse files Browse the repository at this point in the history
…eing in use.
  • Loading branch information
alex-signal authored and greyson-signal committed Nov 21, 2024
1 parent a9c37a9 commit 5f67bd9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ class CallLinkDetailsFragment : ComposeFragment(), CallLinkDetailsCallback {
lifecycleDisposable += viewModel.delete().observeOn(AndroidSchedulers.mainThread()).subscribeBy(onSuccess = {
when (it) {
is UpdateCallLinkResult.Delete -> ActivityCompat.finishAfterTransition(requireActivity())
is UpdateCallLinkResult.CallLinkIsInUse -> {
Log.w(TAG, "Failed to delete in-use call link.")
toastCouldNotDeleteCallLink()
}
else -> {
Log.w(TAG, "Failed to revoke. $it")
Log.w(TAG, "Failed to delete call link. $it")
toastFailure()
}
}
Expand Down Expand Up @@ -188,6 +192,10 @@ class CallLinkDetailsFragment : ComposeFragment(), CallLinkDetailsCallback {
private fun toastFailure() {
Toast.makeText(requireContext(), R.string.CallLinkDetailsFragment__couldnt_save_changes, Toast.LENGTH_LONG).show()
}

private fun toastCouldNotDeleteCallLink() {
Toast.makeText(requireContext(), R.string.CallLinkDetailsFragment__couldnt_delete_call_link, Toast.LENGTH_LONG).show()
}
}

private interface CallLinkDetailsCallback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ class SignalCallLinkManager(
if (result.isSuccess && result.value == true) {
emitter.onSuccess(UpdateCallLinkResult.Delete(credentials.roomId))
} else {
emitter.onSuccess(UpdateCallLinkResult.Failure(result.status))
when (result.status) {
409.toShort() -> emitter.onSuccess(UpdateCallLinkResult.CallLinkIsInUse)
else -> emitter.onSuccess(UpdateCallLinkResult.Failure(result.status))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ sealed interface UpdateCallLinkResult {
val status: Short
) : UpdateCallLinkResult

object NotAuthorized : UpdateCallLinkResult
/**
* Occurs when a user tries to delete a call link that
* the call server believes is currently being utilized.
*/
data object CallLinkIsInUse : UpdateCallLinkResult

data object NotAuthorized : UpdateCallLinkResult
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7209,6 +7209,8 @@
<string name="CallLinkDetailsFragment__delete_call_link">Delete call link</string>
<!-- Displayed whenever a name change, revocation, etc, fails. -->
<string name="CallLinkDetailsFragment__couldnt_save_changes">Couldn\'t save changes. Check your network connection and try again.</string>
<!-- Displayed when the call link is in use when the user tries to delete it -->
<string name="CallLinkDetailsFragment__couldnt_delete_call_link">Couldn\'t delete call link as it is currently in use.</string>
<!-- Displayed as title in dialog when user attempts to delete the link -->
<string name="CallLinkDetailsFragment__delete_link">Delete link?</string>
<!-- Displayed as body in dialog when user attempts to delete the link -->
Expand Down

0 comments on commit 5f67bd9

Please sign in to comment.