From 919567dbdbb740566951cf13fe81e600f1b0f954 Mon Sep 17 00:00:00 2001 From: Koen J Date: Thu, 5 Jun 2025 08:52:59 +0200 Subject: [PATCH] Made sync dialogs more robust. --- .../futo/platformplayer/states/StateSync.kt | 74 +++++++++++-------- app/src/stable/assets/sources/dailymotion | 2 +- app/src/stable/assets/sources/odysee | 2 +- app/src/stable/assets/sources/patreon | 2 +- app/src/stable/assets/sources/peertube | 2 +- app/src/stable/assets/sources/rumble | 2 +- app/src/stable/assets/sources/soundcloud | 2 +- app/src/stable/assets/sources/spotify | 2 +- app/src/stable/assets/sources/youtube | 2 +- .../unstable/assets/sources/apple-podcasts | 2 +- app/src/unstable/assets/sources/bitchute | 2 +- app/src/unstable/assets/sources/dailymotion | 2 +- app/src/unstable/assets/sources/odysee | 2 +- app/src/unstable/assets/sources/patreon | 2 +- app/src/unstable/assets/sources/peertube | 2 +- app/src/unstable/assets/sources/rumble | 2 +- app/src/unstable/assets/sources/soundcloud | 2 +- app/src/unstable/assets/sources/spotify | 2 +- app/src/unstable/assets/sources/youtube | 2 +- 19 files changed, 61 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/states/StateSync.kt b/app/src/main/java/com/futo/platformplayer/states/StateSync.kt index fd08165c..2303e3bc 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StateSync.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StateSync.kt @@ -84,16 +84,20 @@ class StateSync { onUnauthorized = { sess -> StateApp.instance.scope.launch(Dispatchers.Main) { - UIDialogs.showConfirmationDialog( - context, - "Device Unauthorized: ${sess.displayName}", - action = { - Logger.i(TAG, "${sess.remotePublicKey} unauthorized received") - removeAuthorizedDevice(sess.remotePublicKey) - deviceRemoved.emit(sess.remotePublicKey) - }, - cancelAction = {} - ) + try { + UIDialogs.showConfirmationDialog( + context, + "Device Unauthorized: ${sess.displayName}", + action = { + Logger.i(TAG, "${sess.remotePublicKey} unauthorized received") + removeAuthorizedDevice(sess.remotePublicKey) + deviceRemoved.emit(sess.remotePublicKey) + }, + cancelAction = {} + ) + } catch (e: Throwable) { + Logger.e(TAG, "Failed to show unauthorized dialog.", e) + } } } @@ -118,30 +122,38 @@ class StateSync { if (scope != null && activity != null) { scope.launch(Dispatchers.Main) { - UIDialogs.showConfirmationDialog(activity, "Allow connection from $remotePublicKey?", - action = { - scope.launch(Dispatchers.IO) { - try { - callback(true) - Logger.i(TAG, "Connection authorized for $remotePublicKey by confirmation") + try { + UIDialogs.showConfirmationDialog( + activity, "Allow connection from $remotePublicKey?", + action = { + scope.launch(Dispatchers.IO) { + try { + callback(true) + Logger.i( + TAG, + "Connection authorized for $remotePublicKey by confirmation" + ) - activity.finish() - } catch (e: Throwable) { - Logger.e(TAG, "Failed to send authorize", e) + activity.finish() + } catch (e: Throwable) { + Logger.e(TAG, "Failed to send authorize", e) + } + } + }, + cancelAction = { + scope.launch(Dispatchers.IO) { + try { + callback(false) + Logger.i(TAG, "$remotePublicKey unauthorized received") + } catch (e: Throwable) { + Logger.w(TAG, "Failed to send unauthorize", e) + } } } - }, - cancelAction = { - scope.launch(Dispatchers.IO) { - try { - callback(false) - Logger.i(TAG, "$remotePublicKey unauthorized received") - } catch (e: Throwable) { - Logger.w(TAG, "Failed to send unauthorize", e) - } - } - } - ) + ) + } catch (e: Throwable) { + Logger.e(TAG, "Failed to show authorized dialog.", e) + } } } else { callback(false) diff --git a/app/src/stable/assets/sources/dailymotion b/app/src/stable/assets/sources/dailymotion index d1154300..ffd40f20 160000 --- a/app/src/stable/assets/sources/dailymotion +++ b/app/src/stable/assets/sources/dailymotion @@ -1 +1 @@ -Subproject commit d11543001150f96f3383d83fec3341d9321746b8 +Subproject commit ffd40f2006b9048690944e55688951a849f5a13a diff --git a/app/src/stable/assets/sources/odysee b/app/src/stable/assets/sources/odysee index 6ea9fa7e..215cd9bd 160000 --- a/app/src/stable/assets/sources/odysee +++ b/app/src/stable/assets/sources/odysee @@ -1 +1 @@ -Subproject commit 6ea9fa7e4c20ba8c89975ac835ccebdbd1184fc4 +Subproject commit 215cd9bd70d3cc68e25441f7696dcbe5beee2709 diff --git a/app/src/stable/assets/sources/patreon b/app/src/stable/assets/sources/patreon index d98c7f8a..e5dce87c 160000 --- a/app/src/stable/assets/sources/patreon +++ b/app/src/stable/assets/sources/patreon @@ -1 +1 @@ -Subproject commit d98c7f8aee36101d60a0c671d16a0800d5d715d0 +Subproject commit e5dce87c9d8ae7571df40a6fa252404e18b963f1 diff --git a/app/src/stable/assets/sources/peertube b/app/src/stable/assets/sources/peertube index 56bff391..6e7f943b 160000 --- a/app/src/stable/assets/sources/peertube +++ b/app/src/stable/assets/sources/peertube @@ -1 +1 @@ -Subproject commit 56bff391239e676e7d347ad3730df17795938a7b +Subproject commit 6e7f943b0ba56181ee503e1f2cb8349db1351553 diff --git a/app/src/stable/assets/sources/rumble b/app/src/stable/assets/sources/rumble index 3bbce817..932fdf78 160000 --- a/app/src/stable/assets/sources/rumble +++ b/app/src/stable/assets/sources/rumble @@ -1 +1 @@ -Subproject commit 3bbce81794b175410fe79a12c28f9ba966de07da +Subproject commit 932fdf78dec23a132bedc8838185af9911452af5 diff --git a/app/src/stable/assets/sources/soundcloud b/app/src/stable/assets/sources/soundcloud index 54564312..f8234d6a 160000 --- a/app/src/stable/assets/sources/soundcloud +++ b/app/src/stable/assets/sources/soundcloud @@ -1 +1 @@ -Subproject commit 54564312683a0ae06d7085405478f96cade325e3 +Subproject commit f8234d6af8573414d07fd364bc136aa67ad0e379 diff --git a/app/src/stable/assets/sources/spotify b/app/src/stable/assets/sources/spotify index 1d884f50..47e76a96 160000 --- a/app/src/stable/assets/sources/spotify +++ b/app/src/stable/assets/sources/spotify @@ -1 +1 @@ -Subproject commit 1d884f50abf88acf8fec77cefda2f6ffa0d932b5 +Subproject commit 47e76a96e5edcb265b99e2e30f178ba6234a6d2f diff --git a/app/src/stable/assets/sources/youtube b/app/src/stable/assets/sources/youtube index 6d6838e2..a297a0a7 160000 --- a/app/src/stable/assets/sources/youtube +++ b/app/src/stable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit 6d6838e2a472786e652521bd5fa0dff8f9364dc2 +Subproject commit a297a0a7884ea2cf1aa4c9798d72ee11d0038dce diff --git a/app/src/unstable/assets/sources/apple-podcasts b/app/src/unstable/assets/sources/apple-podcasts index 089987f0..9aa31c5e 160000 --- a/app/src/unstable/assets/sources/apple-podcasts +++ b/app/src/unstable/assets/sources/apple-podcasts @@ -1 +1 @@ -Subproject commit 089987f007319cf22972090a0cb09afd8c008adb +Subproject commit 9aa31c5e87c7957a6e7ef07b6a8f38b775c88d9a diff --git a/app/src/unstable/assets/sources/bitchute b/app/src/unstable/assets/sources/bitchute index b213f91c..b31ced36 160000 --- a/app/src/unstable/assets/sources/bitchute +++ b/app/src/unstable/assets/sources/bitchute @@ -1 +1 @@ -Subproject commit b213f91c0b0e61622dd7e3c0a7b5f6a46973321c +Subproject commit b31ced36b9faaa535fb13a5873cdeb1c89d55859 diff --git a/app/src/unstable/assets/sources/dailymotion b/app/src/unstable/assets/sources/dailymotion index d1154300..ffd40f20 160000 --- a/app/src/unstable/assets/sources/dailymotion +++ b/app/src/unstable/assets/sources/dailymotion @@ -1 +1 @@ -Subproject commit d11543001150f96f3383d83fec3341d9321746b8 +Subproject commit ffd40f2006b9048690944e55688951a849f5a13a diff --git a/app/src/unstable/assets/sources/odysee b/app/src/unstable/assets/sources/odysee index 6ea9fa7e..215cd9bd 160000 --- a/app/src/unstable/assets/sources/odysee +++ b/app/src/unstable/assets/sources/odysee @@ -1 +1 @@ -Subproject commit 6ea9fa7e4c20ba8c89975ac835ccebdbd1184fc4 +Subproject commit 215cd9bd70d3cc68e25441f7696dcbe5beee2709 diff --git a/app/src/unstable/assets/sources/patreon b/app/src/unstable/assets/sources/patreon index d98c7f8a..e5dce87c 160000 --- a/app/src/unstable/assets/sources/patreon +++ b/app/src/unstable/assets/sources/patreon @@ -1 +1 @@ -Subproject commit d98c7f8aee36101d60a0c671d16a0800d5d715d0 +Subproject commit e5dce87c9d8ae7571df40a6fa252404e18b963f1 diff --git a/app/src/unstable/assets/sources/peertube b/app/src/unstable/assets/sources/peertube index 56bff391..6e7f943b 160000 --- a/app/src/unstable/assets/sources/peertube +++ b/app/src/unstable/assets/sources/peertube @@ -1 +1 @@ -Subproject commit 56bff391239e676e7d347ad3730df17795938a7b +Subproject commit 6e7f943b0ba56181ee503e1f2cb8349db1351553 diff --git a/app/src/unstable/assets/sources/rumble b/app/src/unstable/assets/sources/rumble index 3bbce817..932fdf78 160000 --- a/app/src/unstable/assets/sources/rumble +++ b/app/src/unstable/assets/sources/rumble @@ -1 +1 @@ -Subproject commit 3bbce81794b175410fe79a12c28f9ba966de07da +Subproject commit 932fdf78dec23a132bedc8838185af9911452af5 diff --git a/app/src/unstable/assets/sources/soundcloud b/app/src/unstable/assets/sources/soundcloud index 54564312..f8234d6a 160000 --- a/app/src/unstable/assets/sources/soundcloud +++ b/app/src/unstable/assets/sources/soundcloud @@ -1 +1 @@ -Subproject commit 54564312683a0ae06d7085405478f96cade325e3 +Subproject commit f8234d6af8573414d07fd364bc136aa67ad0e379 diff --git a/app/src/unstable/assets/sources/spotify b/app/src/unstable/assets/sources/spotify index 1d884f50..47e76a96 160000 --- a/app/src/unstable/assets/sources/spotify +++ b/app/src/unstable/assets/sources/spotify @@ -1 +1 @@ -Subproject commit 1d884f50abf88acf8fec77cefda2f6ffa0d932b5 +Subproject commit 47e76a96e5edcb265b99e2e30f178ba6234a6d2f diff --git a/app/src/unstable/assets/sources/youtube b/app/src/unstable/assets/sources/youtube index 6d6838e2..a297a0a7 160000 --- a/app/src/unstable/assets/sources/youtube +++ b/app/src/unstable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit 6d6838e2a472786e652521bd5fa0dff8f9364dc2 +Subproject commit a297a0a7884ea2cf1aa4c9798d72ee11d0038dce