diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 02ebb28..fa4a0a1 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -65,7 +65,7 @@ When possible, use immutable collections instead of the mutable equivalent. For When possible, we prefer not to create global variables or methods. You can usually replace a global variable with a Riverpod controller, and a global method with an extension method. -I'm also not a big fan of private methods or variables, but this is contextual. +I'm also not a big fan of unneeded private methods or variables, but this is contextual. ### Modern Dart syntax diff --git a/gomuks b/gomuks index 38e5033..ad275f7 160000 --- a/gomuks +++ b/gomuks @@ -1 +1 @@ -Subproject commit 38e5033c3a91db0cbea6cbd9f0feef9ff6441038 +Subproject commit ad275f7613894d9d2fa4d16d733a6816e2978de9 diff --git a/lib/controllers/gomuks_listener.dart b/lib/controllers/gomuks_listener.dart index ef536c7..62c16c5 100644 --- a/lib/controllers/gomuks_listener.dart +++ b/lib/controllers/gomuks_listener.dart @@ -1,5 +1,6 @@ import "dart:async"; import "dart:ffi"; +import "dart:isolate"; import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:flutter/foundation.dart"; @@ -112,12 +113,20 @@ class GomuksListenerController extends AsyncNotifier { ref.onDispose(callable.close); - final errorCode = GomuksStart(handle, callable.nativeFunction); + final errorCode = await _start(handle, callable.nativeFunction); if (errorCode != 0) { throw Exception("GomuksStart returned error code $errorCode"); } } + static Future _start( + int handle, + Pointer< + NativeFunction, Int64, GomuksOwnedBuffer)> + > + callback, + ) => Isolate.run(() => GomuksStart(handle, callback)); + static final provider = AsyncNotifierProvider( GomuksListenerController.new, ); diff --git a/lib/main.dart b/lib/main.dart index 3501d5c..94469cc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,6 +5,7 @@ import "package:flutter/foundation.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:material_emoji_picker/material_emoji_picker.dart"; import "package:media_kit/media_kit.dart"; +import "package:nexus/controllers/client.dart"; import "package:nexus/controllers/client_state.dart"; import "package:nexus/controllers/gomuks_listener.dart"; import "package:nexus/controllers/key.dart"; @@ -193,6 +194,7 @@ class const App({super.key}) extends StatelessWidget { AsyncError(:final error, :final stackTrace) => ErrorDialog( error, stackTrace, + provider: ClientController.provider, ), }, ),