Compare commits

..
6 changed files with 12 additions and 10 deletions

View file

@ -108,7 +108,7 @@ class ClientController extends AsyncNotifier<int> {
() => callback(handle, bufferPointer.ref),
);
final json = response.buf.toJsonAndFree();
final json = response.buf.toJson();
if (response.command.cast<Utf8>().toDartString() == "error") {
throw json;

View file

@ -35,7 +35,7 @@ class GomuksListenerController extends AsyncNotifier<void> {
try {
final muksEventType = command.cast<Utf8>().toDartString();
debugPrint("Handling $muksEventType...");
final decodedMuksEvent = data.toJsonAndFree();
final decodedMuksEvent = data.toJson();
switch (muksEventType) {
case "client_state":

View file

@ -3,6 +3,7 @@ import "dart:convert";
import "dart:io";
import "package:flutter/foundation.dart";
import "package:flutter/services.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:intl/intl.dart";
import "package:nexus/controllers/key.dart";
@ -77,7 +78,7 @@ class UnifiedPushController extends AsyncNotifier<bool> {
KeyController.provider(KeyController.roomKey).future,
) ==
event.roomId)) {
if (isInBackground) exit(0);
if (isInBackground) SystemNavigator.pop();
return;
}
@ -103,7 +104,7 @@ class UnifiedPushController extends AsyncNotifier<bool> {
},
);
if (isInBackground) exit(0);
if (isInBackground) SystemNavigator.pop();
},
onUnregistered: deregister,
);

View file

@ -1,21 +1,20 @@
import "dart:convert";
import "dart:ffi";
import "dart:typed_data";
import "package:ffi/ffi.dart";
import "package:nexus/src/third_party/gomuks.g.dart";
extension GomuksOwnedBufferToX on GomuksOwnedBuffer {
Uint8List toBytesAndFree() {
Uint8List toBytes() {
try {
if (base == nullptr || length <= 0) return .new(0);
return .fromList(base.asTypedList(length));
} finally {
GomuksFreeBuffer(this);
calloc.free(base);
}
}
dynamic toJsonAndFree() => jsonDecode(utf8.decode(toBytesAndFree()));
dynamic toJson() => jsonDecode(utf8.decode(toBytes()));
}
extension JsonToGomuksBuffer on Map<String, dynamic> {

View file

@ -2,6 +2,7 @@ import "dart:io";
import "package:dynamic_color/dynamic_color.dart";
import "package:flutter/foundation.dart";
import "package:flutter/services.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:material_emoji_picker/material_emoji_picker.dart";
import "package:media_kit/media_kit.dart";
@ -79,7 +80,7 @@ void main(List<String> args) async {
.timeout(Duration(seconds: 5));
await Future.delayed(Duration(seconds: 10));
exit(0);
SystemNavigator.pop();
} else {
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
await windowManager.ensureInitialized();

View file

@ -1,6 +1,7 @@
import "dart:io";
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter/services.dart";
import "package:material_ui/material_ui.dart";
import "package:hooks_riverpod/hooks_riverpod.dart";
import "package:nexus/controllers/settings.dart";
@ -59,7 +60,7 @@ final class const Appbar({
),
IconButton(
tooltip: "Close window",
onPressed: () => exit(0),
onPressed: SystemNavigator.pop,
icon: const Icon(Icons.close),
),
],