fix: Database corruption because notification tab isolate starts too late
This commit is contained in:
parent
582797b5f6
commit
92fcfacfc4
2 changed files with 14 additions and 1 deletions
|
|
@ -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…
Add table
Reference in a new issue