@@ -36,6 +36,7 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.
36
36
import 'package:fluffychat/utils/push_helper.dart' ;
37
37
import '../config/app_config.dart' ;
38
38
import '../config/setting_keys.dart' ;
39
+ import '../widgets/fluffy_chat_app.dart' ;
39
40
import 'famedlysdk_store.dart' ;
40
41
import 'platform_infos.dart' ;
41
42
@@ -51,7 +52,7 @@ class BackgroundPush {
51
52
FlutterLocalNotificationsPlugin ();
52
53
Client client;
53
54
BuildContext ? context;
54
- GlobalKey <VRouterState >? router;
55
+ GlobalKey <VRouterState > get router => FluffyChatApp .routerKey ;
55
56
String ? _fcmToken;
56
57
void Function (String errorMsg, {Uri ? link})? onFcmError;
57
58
L10n ? l10n;
@@ -82,7 +83,7 @@ class BackgroundPush {
82
83
),
83
84
client: client,
84
85
l10n: l10n,
85
- activeRoomId: router? .currentState? .pathParameters['roomid' ],
86
+ activeRoomId: router.currentState? .pathParameters['roomid' ],
86
87
onSelectNotification: goToRoom,
87
88
),
88
89
);
@@ -103,15 +104,12 @@ class BackgroundPush {
103
104
104
105
factory BackgroundPush (
105
106
Client client,
106
- BuildContext context,
107
- GlobalKey <VRouterState >? router, {
107
+ BuildContext context, {
108
108
final void Function (String errorMsg, {Uri ? link})? onFcmError,
109
109
}) {
110
110
final instance = BackgroundPush .clientOnly (client);
111
111
instance.context = context;
112
112
// ignore: prefer_initializing_formals
113
- instance.router = router;
114
- // ignore: prefer_initializing_formals
115
113
instance.onFcmError = onFcmError;
116
114
return instance;
117
115
}
@@ -233,7 +231,7 @@ class BackgroundPush {
233
231
if (details == null ||
234
232
! details.didNotificationLaunchApp ||
235
233
_wentToRoomOnStartup ||
236
- router == null ) {
234
+ router.currentState == null ) {
237
235
return ;
238
236
}
239
237
_wentToRoomOnStartup = true ;
@@ -285,7 +283,7 @@ class BackgroundPush {
285
283
try {
286
284
final roomId = response? .payload;
287
285
Logs ().v ('[Push] Attempting to go to room $roomId ...' );
288
- if (router == null || roomId == null ) {
286
+ if (router.currentState == null || roomId == null ) {
289
287
return ;
290
288
}
291
289
await client.roomsLoading;
@@ -296,7 +294,7 @@ class BackgroundPush {
296
294
? .content
297
295
.tryGet <String >('type' ) ==
298
296
ClientStoriesExtension .storiesRoomType;
299
- router! .currentState! .toSegments ([isStory ? 'stories' : 'rooms' , roomId]);
297
+ router.currentState! .toSegments ([isStory ? 'stories' : 'rooms' , roomId]);
300
298
} catch (e, s) {
301
299
Logs ().e ('[Push] Failed to open room' , e, s);
302
300
}
@@ -376,7 +374,7 @@ class BackgroundPush {
376
374
PushNotification .fromJson (data),
377
375
client: client,
378
376
l10n: l10n,
379
- activeRoomId: router? .currentState? .pathParameters['roomid' ],
377
+ activeRoomId: router.currentState? .pathParameters['roomid' ],
380
378
);
381
379
}
382
380
0 commit comments