Skip to content

Commit

Permalink
feat: mark notifications as read on tap (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon authored Oct 26, 2024
1 parent 99949f3 commit 485608b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions lib/provider/message_opened_app_notifier_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:collection/collection.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'api/i_notifier_provider.dart';
import 'notes_notifier_provider.dart';
import 'push_notification_notifier_provider.dart';
import 'user_ids_notifier_provider.dart';
Expand Down Expand Up @@ -42,16 +43,13 @@ class MessageOpenedAppNotifier extends _$MessageOpenedAppNotifier {
return null;
}

try {
if (notification.body?.note?.id case final noteId?) {
unawaited(
ref.read(notesNotifierProvider(account).notifier).show(noteId),
);
return '/$account/notes/$noteId';
} else if (notification.body?.userId case final userId?) {
return '/$account/users/$userId';
}
} catch (_) {}
ref.read(iNotifierProvider(account).notifier).readNotifications().ignore();
if (notification.body?.note?.id case final noteId?) {
ref.read(notesNotifierProvider(account).notifier).show(noteId).ignore();
return '/$account/notes/$noteId';
} else if (notification.body?.userId case final userId?) {
return '/$account/users/$userId';
}
return '/$account/notifications';
}
}
2 changes: 1 addition & 1 deletion lib/provider/message_opened_app_notifier_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 485608b

Please sign in to comment.