diff --git a/app/src/main/java/org/thoughtcrime/securesms/calls/links/details/CallLinkDetailsFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/calls/links/details/CallLinkDetailsFragment.kt
index 5823f288b46..1d69f29137d 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/calls/links/details/CallLinkDetailsFragment.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/calls/links/details/CallLinkDetailsFragment.kt
@@ -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()
}
}
@@ -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 {
diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/links/SignalCallLinkManager.kt b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/links/SignalCallLinkManager.kt
index 16926e7fc4d..d86b934b06c 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/links/SignalCallLinkManager.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/links/SignalCallLinkManager.kt
@@ -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))
+ }
}
}
}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/links/UpdateCallLinkResult.kt b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/links/UpdateCallLinkResult.kt
index 2d72d138b7e..d8b72498c65 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/links/UpdateCallLinkResult.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/links/UpdateCallLinkResult.kt
@@ -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
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index db71bf4d5f8..f6b513f0a1b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -7209,6 +7209,8 @@
Delete call link
Couldn\'t save changes. Check your network connection and try again.
+
+ Couldn\'t delete call link as it is currently in use.
Delete link?