fix: Database corruption because notification tab isolate starts too late

pull/2337/head
Christian Kußowski 2 months ago
parent 582797b5f6
commit 92fcfacfc4
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -1,3 +1,6 @@
import 'dart:isolate';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:collection/collection.dart';
@ -12,12 +15,22 @@ import 'config/setting_keys.dart';
import 'utils/background_push.dart';
import 'widgets/fluffy_chat_app.dart';
ReceivePort? mainIsolateReceivePort;
void main() async {
// Our background push shared isolate accesses flutter-internal things very early in the startup proccess
// To make sure that the parts of flutter needed are started up already, we need to ensure that the
// widget bindings are initialized already.
WidgetsFlutterBinding.ensureInitialized();
if (PlatformInfos.isAndroid) {
final port = mainIsolateReceivePort = ReceivePort();
IsolateNameServer.registerPortWithName(
port.sendPort,
'main_isolate',
);
}
final store = await AppSettings.init();
Logs().i('Welcome to ${AppSettings.applicationName.value} <3');

@ -48,7 +48,7 @@ void notificationTapBackground(
) async {
Logs().i('Notification tap in background');
final sendPort = IsolateNameServer.lookupPortByName('background_tab_port');
final sendPort = IsolateNameServer.lookupPortByName('main_isolate');
if (sendPort != null) {
sendPort.send(notificationResponse.toJsonString());
return;

Loading…
Cancel
Save