diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt index cb3636fe..ff7b8bce 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt @@ -316,10 +316,8 @@ class TunnelListFragment : BaseFragment() { Application.getTunnelManager().tunnels.thenAccept { tunnels -> val tunnelsToDelete = ArrayList() for (position in copyCheckedItems) tunnelsToDelete.add(tunnels[position]) - val futures = tunnelsToDelete - .map { obj -> obj.delete() } - .toTypedArray() - CompletableFuture.allOf(*futures as Array>) + val futures = tunnelsToDelete.map { it.delete().toCompletableFuture() }.toTypedArray() + CompletableFuture.allOf(*futures) .thenApply { futures.size } .whenComplete(this@TunnelListFragment::onTunnelDeletionFinished) }