Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Potential fix for notification order

Neeraj Guptaa10972319bc3
diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart
index bf02a5c018..09126649df 100644
--- a/mobile/lib/main.dart
+++ b/mobile/lib/main.dart
@@ -40,6 +40,7 @@ import 'package:photos/services/machine_learning/ml_service.dart';
import 'package:photos/services/machine_learning/semantic_search/semantic_search_service.dart';
import "package:photos/services/magic_cache_service.dart";
import 'package:photos/services/memories_service.dart';
+import "package:photos/services/notification_service.dart";
import 'package:photos/services/push_service.dart';
import 'package:photos/services/remote_sync_service.dart';
import 'package:photos/services/search_service.dart';
@@ -209,6 +210,7 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
await _logFGHeartBeatInfo();
_logger.info("_logFGHeartBeatInfo done");
unawaited(_scheduleHeartBeat(preferences, isBackground));
+ NotificationService.instance.init(preferences);
AppLifecycleService.instance.init(preferences);
if (isBackground) {
AppLifecycleService.instance.onAppInBackground('init via: $via');
diff --git a/mobile/lib/services/notification_service.dart b/mobile/lib/services/notification_service.dart
index c860f427f8..b99c3bcb0f 100644
--- a/mobile/lib/services/notification_service.dart
+++ b/mobile/lib/services/notification_service.dart
@@ -20,13 +20,15 @@ class NotificationService {
FlutterLocalNotificationsPlugin();
final _logger = Logger("NotificationService");
- Future<void> init(
+ void init(SharedPreferences preferences) {
+ _preferences = preferences;
+ }
+
+ Future<void> initialize(
void Function(
NotificationResponse notificationResponse,
) onNotificationTapped,
- SharedPreferences preferences,
) async {
- _preferences = preferences;
const androidSettings = AndroidInitializationSettings('notification_icon');
const iosSettings = DarwinInitializationSettings(
requestAlertPermission: false,
diff --git a/mobile/lib/ui/tabs/home_widget.dart b/mobile/lib/ui/tabs/home_widget.dart
index dd31dbeda6..1cd4312ffe 100644
--- a/mobile/lib/ui/tabs/home_widget.dart
+++ b/mobile/lib/ui/tabs/home_widget.dart
@@ -57,7 +57,6 @@ import 'package:photos/ui/viewer/search_tab/search_tab.dart';
import 'package:photos/utils/dialog_util.dart';
import "package:photos/utils/navigation_util.dart";
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
-import "package:shared_preferences/shared_preferences.dart";
import 'package:uni_links/uni_links.dart';
class HomeWidget extends StatefulWidget {
@@ -105,6 +104,7 @@ class _HomeWidgetState extends State<HomeWidget> {
@override
void initState() {
_logger.info("Building initstate");
+ super.initState();
_tabChangedEventSubscription =
Bus.instance.on<TabChangedEvent>().listen((event) {
_selectedTabIndex = event.selectedIndex;
@@ -221,13 +221,9 @@ class _HomeWidgetState extends State<HomeWidget> {
},
),
);
-
- SharedPreferences.getInstance().then((preferences) {
- NotificationService.instance
- .init(_onDidReceiveNotificationResponse, preferences);
- });
-
- super.initState();
+ NotificationService.instance
+ .initialize(_onDidReceiveNotificationResponse)
+ .ignore();
}
Future<void> _autoLogoutAlert() async {