From 034d0616c28adebd083b3e4cd61e458e9e035885 Mon Sep 17 00:00:00 2001 From: Alexandre G Pereira Date: Sun, 18 Aug 2024 13:08:53 -0300 Subject: [PATCH] Fix - menu language changing when changing phone language (#327) --- .../hunter/settings/SettingsStateHolder.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/feature/settings/compose/src/commonMain/kotlin/br/alexandregpereira/hunter/settings/SettingsStateHolder.kt b/feature/settings/compose/src/commonMain/kotlin/br/alexandregpereira/hunter/settings/SettingsStateHolder.kt index a53b26ae..3085a1d3 100644 --- a/feature/settings/compose/src/commonMain/kotlin/br/alexandregpereira/hunter/settings/SettingsStateHolder.kt +++ b/feature/settings/compose/src/commonMain/kotlin/br/alexandregpereira/hunter/settings/SettingsStateHolder.kt @@ -23,7 +23,7 @@ import br.alexandregpereira.hunter.domain.settings.GetAlternativeSourceJsonUrlUs import br.alexandregpereira.hunter.domain.settings.GetMonsterImageJsonUrlUseCase import br.alexandregpereira.hunter.domain.settings.SaveLanguageUseCase import br.alexandregpereira.hunter.domain.settings.SaveUrlsUseCase -import br.alexandregpereira.hunter.localization.AppLocalization +import br.alexandregpereira.hunter.localization.AppReactiveLocalization import br.alexandregpereira.hunter.localization.Language import br.alexandregpereira.hunter.monster.content.event.MonsterContentManagerEvent.Show import br.alexandregpereira.hunter.monster.content.event.MonsterContentManagerEventDispatcher @@ -54,7 +54,7 @@ internal class SettingsStateHolder( private val monsterEventDispatcher: MonsterEventDispatcher, private val shareContentEventDispatcher: ShareContentEventDispatcher, private val analytics: SettingsAnalytics, - private val appLocalization: AppLocalization, + private val appLocalization: AppReactiveLocalization, private val saveLanguage: SaveLanguageUseCase, private val getAppearanceSettings: GetAppearanceSettingsFromMonsters, private val applyAppearanceSettings: ApplyAppearanceSettings, @@ -65,9 +65,16 @@ internal class SettingsStateHolder( private var originalSettingsState: SettingsState = SettingsState() init { + observeLanguageChanges() load() } + private fun observeLanguageChanges() { + appLocalization.languageFlow.onEach { + load() + }.launchIn(scope) + } + override fun onImageBaseUrlChange(value: String) { setState { copy(imageBaseUrl = value) } }