From 9146d44cae2d9f4f520343567966784751547684 Mon Sep 17 00:00:00 2001 From: Stef Tervelde Date: Thu, 15 Jan 2026 11:30:23 +0100 Subject: [PATCH] Make `CapturePreferences` only keep track of changes Before `CapturePreferences` would override `LocalPreferences` and halt any changes upstream until `apply` was called, now it will let those changes slip through so we get immediate feedback on changes made in the preferences screen. --- app/src/processing/app/ui/PDEPreferences.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/processing/app/ui/PDEPreferences.kt b/app/src/processing/app/ui/PDEPreferences.kt index ac5bf2609..a4201d09b 100644 --- a/app/src/processing/app/ui/PDEPreferences.kt +++ b/app/src/processing/app/ui/PDEPreferences.kt @@ -441,7 +441,7 @@ private val LocalModifiablePreferences = compositionLocalOf { ModifiablePreference(null, false, { }, {}) } /** - * Composable function that provides a modifiable copy of the current preferences. + * Composable function that captures an initial copy of the current preferences. * This allows for temporary changes to preferences that can be reset or applied later. * * @param content The composable content that will have access to the modifiable preferences. @@ -498,13 +498,13 @@ private fun CapturePreferences(content: @Composable () -> Unit) { } val apply = { - modified.entries.forEach { (key, value) -> - prefs.setProperty(key as String, (value ?: "") as String) + prefs.entries.forEach { (key, value) -> + modified.setProperty(key as String, (value ?: "") as String) } } val reset = { modified.entries.forEach { (key, value) -> - modified.setProperty(key as String, prefs[key] ?: "") + prefs.setProperty(key as String, modified[key] ?: "") } } val state = ModifiablePreference( @@ -515,7 +515,6 @@ private fun CapturePreferences(content: @Composable () -> Unit) { ) CompositionLocalProvider( - LocalPreferences provides modified, LocalModifiablePreferences provides state ) { content()