fix initializing gomobile cwtchdir
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Dan Ballard 2024-02-05 00:06:01 -08:00
parent 74a9656216
commit 581c52a53f
2 changed files with 9 additions and 11 deletions

View File

@ -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<String> 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<void> 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

View File

@ -110,7 +110,6 @@ class FlwtchState extends State<Flwtch> 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());
});