refactor(privacy): move disableClientTag into NIP-78-synced security settings

Aligns the toggle with its Security Filters siblings (warnAboutPostsWithReports,
filterSpamFromStrangers, etc.): stored in AccountSecurityPreferences{Internal},
synced across devices via the app-specific data event, and updated through
account.updateDisableClientTag -> sendNewAppSpecificData.

The signer wrapper now reads the live value from synced settings, so changes
still apply immediately to the next signed event.

https://claude.ai/code/session_01KhNVTm8LLdVphqyxVkZtDS
This commit is contained in:
Claude
2026-05-08 09:23:30 +00:00
parent f1650ad9ce
commit 8559712a55
8 changed files with 34 additions and 12 deletions
@@ -95,7 +95,6 @@ private object PrefKeys {
const val LOCAL_RELAY_SERVERS = "localRelayServers"
const val DEFAULT_FILE_SERVER = "defaultFileServer"
const val STRIP_LOCATION_ON_UPLOAD = "stripLocationOnUpload"
const val DISABLE_CLIENT_TAG = "disableClientTag"
const val DEFAULT_HOME_FOLLOW_LIST = "defaultHomeFollowList"
const val DEFAULT_STORIES_FOLLOW_LIST = "defaultStoriesFollowList"
const val DEFAULT_NOTIFICATION_FOLLOW_LIST = "defaultNotificationFollowList"
@@ -347,7 +346,6 @@ object LocalPreferences {
)
putBoolean(PrefKeys.STRIP_LOCATION_ON_UPLOAD, settings.stripLocationOnUpload)
putBoolean(PrefKeys.DISABLE_CLIENT_TAG, settings.disableClientTag)
putString(PrefKeys.DEFAULT_HOME_FOLLOW_LIST, JsonMapper.toJson(settings.defaultHomeFollowList.value))
putString(PrefKeys.DEFAULT_STORIES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultStoriesFollowList.value))
@@ -515,7 +513,6 @@ object LocalPreferences {
Log.d("LocalPreferences") { "Load account from file $npub - keys ready" }
val stripLocationOnUpload = getBoolean(PrefKeys.STRIP_LOCATION_ON_UPLOAD, true)
val disableClientTag = getBoolean(PrefKeys.DISABLE_CLIENT_TAG, false)
val hideDeleteRequestDialog = getBoolean(PrefKeys.HIDE_DELETE_REQUEST_DIALOG, false)
val hideBlockAlertDialog = getBoolean(PrefKeys.HIDE_BLOCK_ALERT_DIALOG, false)
val hideNIP17WarningDialog = getBoolean(PrefKeys.HIDE_NIP_17_WARNING_DIALOG, false)
@@ -623,7 +620,6 @@ object LocalPreferences {
localRelayServers = MutableStateFlow(localRelayServers),
defaultFileServer = defaultFileServer.await(),
stripLocationOnUpload = stripLocationOnUpload,
disableClientTag = disableClientTag,
defaultHomeFollowList = MutableStateFlow(followListPrefs.home),
defaultStoriesFollowList = MutableStateFlow(followListPrefs.stories),
defaultNotificationFollowList = MutableStateFlow(followListPrefs.notification),
@@ -529,6 +529,14 @@ class Account(
return false
}
suspend fun updateDisableClientTag(disable: Boolean): Boolean {
if (settings.updateDisableClientTag(disable)) {
sendNewAppSpecificData()
return true
}
return false
}
suspend fun updateFilterSpam(filterSpam: Boolean): Boolean {
if (settings.updateFilterSpam(filterSpam)) {
if (!settings.syncedSettings.security.filterSpamFromStrangers.value) {
@@ -149,7 +149,6 @@ class AccountSettings(
var localRelayServers: MutableStateFlow<Set<String>> = MutableStateFlow(setOf()),
var defaultFileServer: ServerName = DEFAULT_MEDIA_SERVERS[0],
var stripLocationOnUpload: Boolean = true,
var disableClientTag: Boolean = false,
val defaultHomeFollowList: MutableStateFlow<TopFilter> = MutableStateFlow(TopFilter.AllFollows),
val defaultStoriesFollowList: MutableStateFlow<TopFilter> = MutableStateFlow(TopFilter.Global),
val defaultNotificationFollowList: MutableStateFlow<TopFilter> = MutableStateFlow(TopFilter.Global),
@@ -404,12 +403,13 @@ class AccountSettings(
}
}
fun changeDisableClientTag(disable: Boolean) {
if (disableClientTag != disable) {
disableClientTag = disable
fun updateDisableClientTag(disable: Boolean): Boolean =
if (syncedSettings.security.updateDisableClientTag(disable)) {
saveAccountSettings()
true
} else {
false
}
}
// ---
// list names
@@ -55,6 +55,7 @@ class AccountSyncedSettings(
MutableStateFlow(internalSettings.security.filterSpamFromStrangers),
MutableStateFlow(internalSettings.security.maxHashtagLimit),
MutableStateFlow(internalSettings.security.sendKind0EventsToLocalRelay),
MutableStateFlow(internalSettings.security.disableClientTag),
)
val videoPlayer =
AccountVideoPlayerPreferences(
@@ -82,6 +83,7 @@ class AccountSyncedSettings(
security.filterSpamFromStrangers.value,
security.maxHashtagLimit.value,
security.sendKind0EventsToLocalRelay.value,
security.disableClientTag.value,
),
videoPlayer = AccountVideoPlayerPreferencesInternal(videoPlayer.buttonItems.value),
)
@@ -138,6 +140,10 @@ class AccountSyncedSettings(
security.sendKind0EventsToLocalRelay.tryEmit(syncedSettingsInternal.security.sendKind0EventsToLocalRelay)
}
if (security.disableClientTag.value != syncedSettingsInternal.security.disableClientTag) {
security.disableClientTag.tryEmit(syncedSettingsInternal.security.disableClientTag)
}
val newVideoPlayerButtonItems = syncedSettingsInternal.videoPlayer.buttonItems.toImmutableList()
if (!equalImmutableLists(videoPlayer.buttonItems.value, newVideoPlayerButtonItems)) {
videoPlayer.buttonItems.tryEmit(newVideoPlayerButtonItems)
@@ -233,6 +239,7 @@ class AccountSecurityPreferences(
var filterSpamFromStrangers: MutableStateFlow<Boolean> = MutableStateFlow(true),
val maxHashtagLimit: MutableStateFlow<Int> = MutableStateFlow(5),
var sendKind0EventsToLocalRelay: MutableStateFlow<Boolean> = MutableStateFlow(false),
val disableClientTag: MutableStateFlow<Boolean> = MutableStateFlow(false),
) {
fun updateShowSensitiveContent(show: Boolean?): Boolean {
if (showSensitiveContent.value != show) {
@@ -273,4 +280,12 @@ class AccountSecurityPreferences(
} else {
false
}
fun updateDisableClientTag(disable: Boolean): Boolean =
if (disable != disableClientTag.value) {
disableClientTag.tryEmit(disable)
true
} else {
false
}
}
@@ -147,4 +147,5 @@ class AccountSecurityPreferencesInternal(
var filterSpamFromStrangers: Boolean = true,
val maxHashtagLimit: Int = 5,
var sendKind0EventsToLocalRelay: Boolean = false,
var disableClientTag: Boolean = false,
)
@@ -139,7 +139,7 @@ class AccountCacheState(
NostrSignerWithClientTag(
inner = signer,
clientName = CLIENT_TAG_NAME,
disabled = { accountSettings.disableClientTag },
disabled = { accountSettings.syncedSettings.security.disableClientTag.value },
)
val accountDir = File(rootFilesDir(), "accounts/${signer.pubKey}").apply { mkdirs() }
@@ -1112,6 +1112,8 @@ class AccountViewModel(
fun updateWarnReports(warnReports: Boolean) = launchSigner { account.updateWarnReports(warnReports) }
fun updateDisableClientTag(disable: Boolean) = launchSigner { account.updateDisableClientTag(disable) }
fun updateFilterSpam(filterSpam: Boolean) =
launchSigner {
if (account.updateFilterSpam(filterSpam)) {
@@ -375,13 +375,13 @@ private fun HeaderOptions(accountViewModel: AccountViewModel) {
R.string.disable_client_tag_title,
R.string.disable_client_tag_explainer,
) {
var disableClientTag by remember { mutableStateOf(accountViewModel.account.settings.disableClientTag) }
var disableClientTag by remember { mutableStateOf(accountViewModel.account.settings.syncedSettings.security.disableClientTag.value) }
Switch(
checked = disableClientTag,
onCheckedChange = {
disableClientTag = it
accountViewModel.account.settings.changeDisableClientTag(it)
accountViewModel.updateDisableClientTag(disableClientTag)
},
)
}