diff --git a/commet/lib/client/matrix/matrix_client.dart b/commet/lib/client/matrix/matrix_client.dart index 4fddec62f..86a9060b1 100644 --- a/commet/lib/client/matrix/matrix_client.dart +++ b/commet/lib/client/matrix/matrix_client.dart @@ -212,7 +212,7 @@ class MatrixClient extends Client { static Future _checkSystem(ClientManager clientManager) async { try { - await vod.init(wasmPath: './assets/assets/vodozemac/'); + await vodozemac.init(wasmPath: './assets/assets/vodozemac/'); if (!vod.isInitialized()) { throw Exception("Vodozemac failed to initialize!"); } diff --git a/commet/lib/main.dart b/commet/lib/main.dart index 61c109c76..7cf347bea 100644 --- a/commet/lib/main.dart +++ b/commet/lib/main.dart @@ -217,6 +217,32 @@ Future initNecessary() async { NeedsPostLoginInit.doPostLoginInit(); } +/// Wrapping the initialization functions in closures prevents an exception +/// "Null check operator used on a null value". Despite the try/catch, +/// the error does not actually occur inside of the closure now. +/// This has the added benefit of providing a stacktrace if there is an +/// error. +Future _loadLocalization(Locale locale) async { + // Wrap the localization initialization functions with a try/catch + // and if there is an exception print the error and stack trace. + Future _load(dynamic Function() loadFunction) async { + try { + await loadFunction(); + } catch (e, st) { + Log.e("Error loading localization: $e\n$st"); + } + } + + return await Future.wait([ + _load(() async => UnicodeEmojis.load()), + if (!preferences.debugTranslations.value) + _load(() async => initializeMessages(locale.languageCode)), + if (preferences.debugTranslations.value) + _load(() async => initializeMessagesDebug()), + _load(() async => initializeDateFormatting(locale.languageCode)), + ]); +} + /// Initializes everything that is needed to run in GUI mode Future initGuiRequirements() async { isHeadless = false; @@ -225,13 +251,7 @@ Future initGuiRequirements() async { var locale = PlatformDispatcher.instance.locale; - Future.wait([ - UnicodeEmojis.load(), - if (!preferences.debugTranslations.value) - initializeMessages(locale.languageCode), - if (preferences.debugTranslations.value) initializeMessagesDebug(), - initializeDateFormatting(locale.languageCode), - ]); + await _loadLocalization(locale); tiamat.getAppScale = () { return preferences.appScale.value; diff --git a/tiamat/lib/config/style/theme_common.dart b/tiamat/lib/config/style/theme_common.dart index 3166ee7b3..e2c6646d0 100644 --- a/tiamat/lib/config/style/theme_common.dart +++ b/tiamat/lib/config/style/theme_common.dart @@ -3,6 +3,11 @@ import 'dart:io' show Platform; class ThemeCommon { static List? fontFamilyFallback() { + // Apple does not render emoji with the default font + // instead use the system-available emoji font. + if (!kIsWeb && (Platform.isMacOS || Platform.isIOS)) { + return ["Apple Color Emoji"]; + } const fonts = ["EmojiFont"]; return fonts; }