From 7f662ec7cc33c98690decaa0fbeec622e0be68cd Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:08:04 +0300 Subject: [PATCH] desktop: theme detector try-catch (#2817) --- .../chat/simplex/common/ui/theme/Theme.desktop.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/ui/theme/Theme.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/ui/theme/Theme.desktop.kt index d7da2fa123..94268002a6 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/ui/theme/Theme.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/ui/theme/Theme.desktop.kt @@ -1,5 +1,7 @@ package chat.simplex.common.ui.theme +import chat.simplex.common.platform.Log +import chat.simplex.common.platform.TAG import com.jthemedetecor.OsThemeDetector private val detector: OsThemeDetector = OsThemeDetector.getDetector() @@ -7,4 +9,11 @@ private val detector: OsThemeDetector = OsThemeDetector.getDetector() registerListener(::reactOnDarkThemeChanges) } -actual fun isSystemInDarkTheme(): Boolean = detector.isDark +actual fun isSystemInDarkTheme(): Boolean = try { + detector.isDark +} +catch (e: Exception) { + Log.e(TAG, e.stackTraceToString()) + /* On Mac this code can produce exception */ + false +}