Fix issue when changing color mode, use update theme instead of updateColor mode

This prevents the Dark theme from being used instead of Black
when changing theme on Android.
This commit is contained in:
Jackson Harper
2023-05-02 16:00:08 +08:00
parent 2feb2067f8
commit a1952fb9e7

View File

@ -290,13 +290,13 @@ class WebReaderViewModel @Inject constructor(
fun updateStoredThemePreference(index: Int, isDarkMode: Boolean) {
val newThemeKey = themeKey(isDarkMode, systemThemeKeys[index])
Log.d("theme", "Setting theme key: ${newThemeKey}")
runBlocking {
datastoreRepo.putString(DatastoreKeys.preferredTheme, systemThemeKeys[index])
}
val isDark = newThemeKey == "Dark" || newThemeKey == "Black"
val script = "var event = new Event('updateColorMode');event.isDark = '$isDark';document.dispatchEvent(event);"
val script = "var event = new Event('updateTheme');event.themeName = '$newThemeKey';document.dispatchEvent(event);"
enqueueScript(script)
}