feat: Add notification actions

pull/1382/head
krille-chan 5 months ago
parent 1817b29442
commit fec0d2c047
No known key found for this signature in database

@ -10,11 +10,20 @@ import 'package:fluffychat/utils/client_manager.dart';
void notificationTapBackground( void notificationTapBackground(
NotificationResponse notificationResponse, NotificationResponse notificationResponse,
) async { ) async {
Logs().i('Notification tap in background');
final client = (await ClientManager.getClients( final client = (await ClientManager.getClients(
initialize: false, initialize: false,
store: await SharedPreferences.getInstance(), store: await SharedPreferences.getInstance(),
)) ))
.first; .first;
await client.abortSync();
await client.init(
waitForFirstSync: false,
waitUntilLoadCompletedLoaded: false,
);
if (!client.isLogged()) {
throw Exception('Notification tab in background but not logged in!');
}
notificationTap(notificationResponse, client: client); notificationTap(notificationResponse, client: client);
} }
@ -23,6 +32,10 @@ void notificationTap(
GoRouter? router, GoRouter? router,
required Client client, required Client client,
}) async { }) async {
Logs().d(
'Notification action handler started',
notificationResponse.notificationResponseType.name,
);
switch (notificationResponse.notificationResponseType) { switch (notificationResponse.notificationResponseType) {
case NotificationResponseType.selectedNotification: case NotificationResponseType.selectedNotification:
final roomId = notificationResponse.payload; final roomId = notificationResponse.payload;

@ -283,9 +283,7 @@ Future<void> _tryPushHelper(
AndroidNotificationAction( AndroidNotificationAction(
FluffyChatNotificationActions.reply.name, FluffyChatNotificationActions.reply.name,
l10n.reply, l10n.reply,
inputs: [ inputs: [const AndroidNotificationActionInput()],
const AndroidNotificationActionInput(),
],
), ),
], ],
); );

Loading…
Cancel
Save