Skip to content

Commit

Permalink
feat: Add notification actions
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Oct 3, 2024
1 parent 932817a commit c0e455b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 13 additions & 0 deletions lib/utils/notification_background_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ import 'package:fluffychat/utils/client_manager.dart';
void notificationTapBackground(
NotificationResponse notificationResponse,
) async {
Logs().i('Notification tap in background');
final client = (await ClientManager.getClients(
initialize: false,
store: await SharedPreferences.getInstance(),
))
.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);
}

Expand All @@ -23,6 +32,10 @@ void notificationTap(
GoRouter? router,
required Client client,
}) async {
Logs().d(
'Notification action handler started',
notificationResponse.notificationResponseType.name,
);
switch (notificationResponse.notificationResponseType) {
case NotificationResponseType.selectedNotification:
final roomId = notificationResponse.payload;
Expand Down
4 changes: 1 addition & 3 deletions lib/utils/push_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,7 @@ Future<void> _tryPushHelper(
AndroidNotificationAction(
FluffyChatNotificationActions.reply.name,
l10n.reply,
inputs: [
const AndroidNotificationActionInput(),
],
inputs: [const AndroidNotificationActionInput()],
),
],
);
Expand Down

0 comments on commit c0e455b

Please sign in to comment.