From 7458d57c2773ba389e3a59a42f8042908274515a Mon Sep 17 00:00:00 2001 From: rhunk <101876869+rhunk@users.noreply.github.com> Date: Mon, 7 Oct 2024 18:11:41 +0200 Subject: [PATCH 1/2] fix(ui/setup): thread exception Method setCurrentState must be called on the main thread --- .../snapenhance/ui/setup/screens/impl/MappingsScreen.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/ui/setup/screens/impl/MappingsScreen.kt b/app/src/main/kotlin/me/rhunk/snapenhance/ui/setup/screens/impl/MappingsScreen.kt index dd785b16..1a52d26c 100644 --- a/app/src/main/kotlin/me/rhunk/snapenhance/ui/setup/screens/impl/MappingsScreen.kt +++ b/app/src/main/kotlin/me/rhunk/snapenhance/ui/setup/screens/impl/MappingsScreen.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import me.rhunk.snapenhance.ui.setup.screens.SetupScreen import me.rhunk.snapenhance.ui.util.AlertDialogs @@ -51,7 +52,9 @@ class MappingsScreen : SetupScreen() { return@launch } - goNext() + withContext(Dispatchers.Main) { + goNext() + } }.onFailure { isGenerating = false infoText = context.translation["setup.mappings.generate_failure"] + "\n\n" + it.message From aa47c7bc6ad3d5e7399b3d08b40d284df7ef7b2d Mon Sep 17 00:00:00 2001 From: rhunk <101876869+rhunk@users.noreply.github.com> Date: Thu, 24 Oct 2024 22:55:44 +0200 Subject: [PATCH 2/2] fix(core): send override Keep the original hasSound attribute when replacing the snap duration --- .../core/features/impl/messaging/SendOverride.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/SendOverride.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/SendOverride.kt index d8a5cd9f..6b6bb15b 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/SendOverride.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/SendOverride.kt @@ -63,9 +63,17 @@ class SendOverride : Feature("Send Override") { } // set back the original snap duration - remove(2) snapDocPlayback.getByteArray(2)?.let { + val originalHasSound = firstOrNull(2)?.toReader()?.getVarInt(5) + remove(2) addBuffer(2, it) + + originalHasSound?.let { hasSound -> + edit(2) { + remove(5) + addVarInt(5, hasSound) + } + } } }