From d4c39bd9cb78c530d774950e07c75bc349b8bbe6 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 11 Sep 2025 10:46:26 -0400 Subject: [PATCH] Adds a flow to TorSettings so that any change to the inner properties can be tracked. --- .../amethyst/ui/tor/TorSettingsFlow.kt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt index e03726f57..d4d765d26 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.ui.tor import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.combine class TorSettingsFlow( val torType: MutableStateFlow = MutableStateFlow(TorType.INTERNAL), @@ -37,6 +38,42 @@ class TorSettingsFlow( val nip05VerificationsViaTor: MutableStateFlow = MutableStateFlow(false), val nip96UploadsViaTor: MutableStateFlow = MutableStateFlow(false), ) { + // emits at every change in any of the propertyes. + val propertyWatchFlow = + combine( + listOf( + torType, + externalSocksPort, + onionRelaysViaTor, + dmRelaysViaTor, + newRelaysViaTor, + trustedRelaysViaTor, + urlPreviewsViaTor, + profilePicsViaTor, + imagesViaTor, + videosViaTor, + moneyOperationsViaTor, + nip05VerificationsViaTor, + nip96UploadsViaTor, + ), + ) { flows -> + TorSettings( + flows[0] as TorType, + flows[1] as Int, + flows[2] as Boolean, + flows[3] as Boolean, + flows[4] as Boolean, + flows[5] as Boolean, + flows[6] as Boolean, + flows[7] as Boolean, + flows[8] as Boolean, + flows[9] as Boolean, + flows[10] as Boolean, + flows[11] as Boolean, + flows[12] as Boolean, + ) + } + fun toSettings(): TorSettings = TorSettings( torType.value,