From 1fdf869c05af10a632ea3117f5a0db0bcc2f9c50 Mon Sep 17 00:00:00 2001 From: davotoula Date: Mon, 6 Oct 2025 18:56:12 +0200 Subject: [PATCH] create putOrRemove overload for Nip47URI? --- .../vitorpamplona/amethyst/LocalPreferences.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 8ffd0646e..77abdf80a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -326,12 +326,7 @@ object LocalPreferences { settings.defaultDiscoveryFollowList.value, ) - val nwcToBeSaved = settings.zapPaymentRequest.value?.denormalize() - if (nwcToBeSaved != null) { - putString(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER, JsonMapper.toJson(nwcToBeSaved)) - } else { - remove(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER) - } + putOrRemove(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER, settings.zapPaymentRequest.value?.denormalize()) putOrRemove(PrefKeys.LATEST_CONTACT_LIST, settings.backupContactList) @@ -589,4 +584,15 @@ object LocalPreferences { remove(key) } } + + fun SharedPreferences.Editor.putOrRemove( + key: String, + nwc: Nip47WalletConnect.Nip47URI?, + ) { + if (nwc != null) { + putString(key, JsonMapper.toJson(nwc)) + } else { + remove(key) + } + } }