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:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
|
@ -12,12 +15,22 @@ import 'config/setting_keys.dart';
|
||||||
import 'utils/background_push.dart';
|
import 'utils/background_push.dart';
|
||||||
import 'widgets/fluffy_chat_app.dart';
|
import 'widgets/fluffy_chat_app.dart';
|
||||||
|
|
||||||
|
ReceivePort? mainIsolateReceivePort;
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
// Our background push shared isolate accesses flutter-internal things very early in the startup proccess
|
// 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
|
// To make sure that the parts of flutter needed are started up already, we need to ensure that the
|
||||||
// widget bindings are initialized already.
|
// widget bindings are initialized already.
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
if (PlatformInfos.isAndroid) {
|
||||||
|
final port = mainIsolateReceivePort = ReceivePort();
|
||||||
|
IsolateNameServer.registerPortWithName(
|
||||||
|
port.sendPort,
|
||||||
|
'main_isolate',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final store = await AppSettings.init();
|
final store = await AppSettings.init();
|
||||||
Logs().i('Welcome to ${AppSettings.applicationName.value} <3');
|
Logs().i('Welcome to ${AppSettings.applicationName.value} <3');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ void notificationTapBackground(
|
||||||
) async {
|
) async {
|
||||||
Logs().i('Notification tap in background');
|
Logs().i('Notification tap in background');
|
||||||
|
|
||||||
final sendPort = IsolateNameServer.lookupPortByName('background_tab_port');
|
final sendPort = IsolateNameServer.lookupPortByName('main_isolate');
|
||||||
if (sendPort != null) {
|
if (sendPort != null) {
|
||||||
sendPort.send(notificationResponse.toJsonString());
|
sendPort.send(notificationResponse.toJsonString());
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue