diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index 89ac928e..164721fa 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -56,7 +56,6 @@ class CwtchGomobile implements Cwtch { cwtchNotifier = _cwtchNotifier; cwtchNotifier.setMessageSeenCallback((String profile, int conversation, DateTime time) => {this.SetConversationAttribute(profile, conversation, LastMessageSeenTimeKey, time.toIso8601String())}); androidHomeDirectory = getApplicationDocumentsDirectory(); - androidLibraryDir = appInfoPlatform.invokeMethod('getNativeLibDir'); // Method channel to receive libcwtch-go events via Kotlin and dispatch them to _handleAppbusEvent (sends to cwtchNotifier) @@ -69,22 +68,22 @@ class CwtchGomobile implements Cwtch { return ""; } + // Requires Start() to have been run to initialize Future getCwtchDir() async { - androidHomeDirectoryStr = (await androidHomeDirectory).path; - var _cwtchDir = path.join(androidHomeDirectoryStr, ".cwtch"); - if (EnvironmentConfig.BUILD_VER == dev_version) { - _cwtchDir = path.join(_cwtchDir, "dev"); - } - return androidHomeDirectoryStr; + return _cwtchDir; } // ignore: non_constant_identifier_names Future Start() async { print("gomobile.dart: Start()..."); + androidHomeDirectoryStr = (await androidHomeDirectory).path; + _cwtchDir = path.join(await androidHomeDirectoryStr, ".cwtch"); + if (EnvironmentConfig.BUILD_VER == dev_version) { + _cwtchDir = path.join(_cwtchDir, "dev"); + } String torPath = path.join(await androidLibraryDir, "libtor.so"); - String cwtchDir = await getCwtchDir(); - print("gomobile.dart: Start invokeMethod Start($cwtchDir, $torPath)..."); - cwtchPlatform.invokeMethod("Start", {"appDir": cwtchDir, "torPath": torPath}); + print("gomobile.dart: Start invokeMethod Start($_cwtchDir, $torPath)..."); + cwtchPlatform.invokeMethod("Start", {"appDir": _cwtchDir, "torPath": torPath}); } @override diff --git a/lib/main.dart b/lib/main.dart index e300dab6..f3d888a0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -110,7 +110,6 @@ class FlwtchState extends State with WindowListener { print("initState: invoking cwtch.Start()"); // Cwtch.start can take time, we don't want it blocking first splash screen draw, so postpone a smidge to let splash render Future.delayed(const Duration(milliseconds: 50), () async { - print("actually invoking cwtch.cwtch()!!!"); await cwtch.Start(); LoadThemes(await cwtch.getCwtchDir()); });