mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +00:00
fix: Click on notification does not open room
This commit is contained in:
parent
8e6ab8a7b3
commit
39adb55b3d
3 changed files with 15 additions and 19 deletions
|
@ -36,6 +36,7 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.
|
||||||
import 'package:fluffychat/utils/push_helper.dart';
|
import 'package:fluffychat/utils/push_helper.dart';
|
||||||
import '../config/app_config.dart';
|
import '../config/app_config.dart';
|
||||||
import '../config/setting_keys.dart';
|
import '../config/setting_keys.dart';
|
||||||
|
import '../widgets/fluffy_chat_app.dart';
|
||||||
import 'famedlysdk_store.dart';
|
import 'famedlysdk_store.dart';
|
||||||
import 'platform_infos.dart';
|
import 'platform_infos.dart';
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ class BackgroundPush {
|
||||||
FlutterLocalNotificationsPlugin();
|
FlutterLocalNotificationsPlugin();
|
||||||
Client client;
|
Client client;
|
||||||
BuildContext? context;
|
BuildContext? context;
|
||||||
GlobalKey<VRouterState>? router;
|
GlobalKey<VRouterState> get router => FluffyChatApp.routerKey;
|
||||||
String? _fcmToken;
|
String? _fcmToken;
|
||||||
void Function(String errorMsg, {Uri? link})? onFcmError;
|
void Function(String errorMsg, {Uri? link})? onFcmError;
|
||||||
L10n? l10n;
|
L10n? l10n;
|
||||||
|
@ -82,7 +83,7 @@ class BackgroundPush {
|
||||||
),
|
),
|
||||||
client: client,
|
client: client,
|
||||||
l10n: l10n,
|
l10n: l10n,
|
||||||
activeRoomId: router?.currentState?.pathParameters['roomid'],
|
activeRoomId: router.currentState?.pathParameters['roomid'],
|
||||||
onSelectNotification: goToRoom,
|
onSelectNotification: goToRoom,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -103,15 +104,12 @@ class BackgroundPush {
|
||||||
|
|
||||||
factory BackgroundPush(
|
factory BackgroundPush(
|
||||||
Client client,
|
Client client,
|
||||||
BuildContext context,
|
BuildContext context, {
|
||||||
GlobalKey<VRouterState>? router, {
|
|
||||||
final void Function(String errorMsg, {Uri? link})? onFcmError,
|
final void Function(String errorMsg, {Uri? link})? onFcmError,
|
||||||
}) {
|
}) {
|
||||||
final instance = BackgroundPush.clientOnly(client);
|
final instance = BackgroundPush.clientOnly(client);
|
||||||
instance.context = context;
|
instance.context = context;
|
||||||
// ignore: prefer_initializing_formals
|
// ignore: prefer_initializing_formals
|
||||||
instance.router = router;
|
|
||||||
// ignore: prefer_initializing_formals
|
|
||||||
instance.onFcmError = onFcmError;
|
instance.onFcmError = onFcmError;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +231,7 @@ class BackgroundPush {
|
||||||
if (details == null ||
|
if (details == null ||
|
||||||
!details.didNotificationLaunchApp ||
|
!details.didNotificationLaunchApp ||
|
||||||
_wentToRoomOnStartup ||
|
_wentToRoomOnStartup ||
|
||||||
router == null) {
|
router.currentState == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_wentToRoomOnStartup = true;
|
_wentToRoomOnStartup = true;
|
||||||
|
@ -285,7 +283,7 @@ class BackgroundPush {
|
||||||
try {
|
try {
|
||||||
final roomId = response?.payload;
|
final roomId = response?.payload;
|
||||||
Logs().v('[Push] Attempting to go to room $roomId...');
|
Logs().v('[Push] Attempting to go to room $roomId...');
|
||||||
if (router == null || roomId == null) {
|
if (router.currentState == null || roomId == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await client.roomsLoading;
|
await client.roomsLoading;
|
||||||
|
@ -296,7 +294,7 @@ class BackgroundPush {
|
||||||
?.content
|
?.content
|
||||||
.tryGet<String>('type') ==
|
.tryGet<String>('type') ==
|
||||||
ClientStoriesExtension.storiesRoomType;
|
ClientStoriesExtension.storiesRoomType;
|
||||||
router!.currentState!.toSegments([isStory ? 'stories' : 'rooms', roomId]);
|
router.currentState!.toSegments([isStory ? 'stories' : 'rooms', roomId]);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logs().e('[Push] Failed to open room', e, s);
|
Logs().e('[Push] Failed to open room', e, s);
|
||||||
}
|
}
|
||||||
|
@ -376,7 +374,7 @@ class BackgroundPush {
|
||||||
PushNotification.fromJson(data),
|
PushNotification.fromJson(data),
|
||||||
client: client,
|
client: client,
|
||||||
l10n: l10n,
|
l10n: l10n,
|
||||||
activeRoomId: router?.currentState?.pathParameters['roomid'],
|
activeRoomId: router.currentState?.pathParameters['roomid'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,6 @@ class FluffyChatAppState extends State<FluffyChatApp> {
|
||||||
builder: (context, child) => Matrix(
|
builder: (context, child) => Matrix(
|
||||||
key: FluffyChatApp.matrixKey,
|
key: FluffyChatApp.matrixKey,
|
||||||
context: context,
|
context: context,
|
||||||
router: FluffyChatApp.routerKey,
|
|
||||||
clients: widget.clients,
|
clients: widget.clients,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
|
|
|
@ -33,6 +33,7 @@ import '../pages/key_verification/key_verification_dialog.dart';
|
||||||
import '../utils/account_bundles.dart';
|
import '../utils/account_bundles.dart';
|
||||||
import '../utils/background_push.dart';
|
import '../utils/background_push.dart';
|
||||||
import '../utils/famedlysdk_store.dart';
|
import '../utils/famedlysdk_store.dart';
|
||||||
|
import 'fluffy_chat_app.dart';
|
||||||
import 'local_notifications_extension.dart';
|
import 'local_notifications_extension.dart';
|
||||||
|
|
||||||
// import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
// import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
@ -40,7 +41,7 @@ import 'local_notifications_extension.dart';
|
||||||
class Matrix extends StatefulWidget {
|
class Matrix extends StatefulWidget {
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
|
|
||||||
final GlobalKey<VRouterState>? router;
|
GlobalKey<VRouterState> get router => FluffyChatApp.routerKey;
|
||||||
|
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
|
|
||||||
|
@ -50,7 +51,6 @@ class Matrix extends StatefulWidget {
|
||||||
|
|
||||||
const Matrix({
|
const Matrix({
|
||||||
this.child,
|
this.child,
|
||||||
required this.router,
|
|
||||||
required this.context,
|
required this.context,
|
||||||
required this.clients,
|
required this.clients,
|
||||||
this.queryParameters,
|
this.queryParameters,
|
||||||
|
@ -177,7 +177,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
ClientManager.addClientNameToStore(_loginClientCandidate!.clientName);
|
ClientManager.addClientNameToStore(_loginClientCandidate!.clientName);
|
||||||
_registerSubs(_loginClientCandidate!.clientName);
|
_registerSubs(_loginClientCandidate!.clientName);
|
||||||
_loginClientCandidate = null;
|
_loginClientCandidate = null;
|
||||||
widget.router!.currentState!.to('/rooms');
|
widget.router.currentState!.to('/rooms');
|
||||||
});
|
});
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
@ -334,15 +334,15 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (state != LoginState.loggedIn) {
|
if (state != LoginState.loggedIn) {
|
||||||
widget.router?.currentState?.to(
|
widget.router.currentState?.to(
|
||||||
'/rooms',
|
'/rooms',
|
||||||
queryParameters: widget.router?.currentState?.queryParameters ?? {},
|
queryParameters: widget.router.currentState?.queryParameters ?? {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
widget.router?.currentState?.to(
|
widget.router.currentState?.to(
|
||||||
state == LoginState.loggedIn ? '/rooms' : '/home',
|
state == LoginState.loggedIn ? '/rooms' : '/home',
|
||||||
queryParameters: widget.router?.currentState?.queryParameters ?? {},
|
queryParameters: widget.router.currentState?.queryParameters ?? {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -407,7 +407,6 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
backgroundPush = BackgroundPush(
|
backgroundPush = BackgroundPush(
|
||||||
client,
|
client,
|
||||||
context,
|
context,
|
||||||
widget.router,
|
|
||||||
onFcmError: (errorMsg, {Uri? link}) async {
|
onFcmError: (errorMsg, {Uri? link}) async {
|
||||||
final result = await showOkCancelAlertDialog(
|
final result = await showOkCancelAlertDialog(
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
|
|
Loading…
Reference in a new issue