markAllAsRead method
Marks all notifications as read.
Implementation
Future<void> markAllAsRead() async {
if (!state.hasData) return;
log('Marking all notifications as read');
final unread = state.requireData.where((element) => !element.read).toList();
if (unread.isEmpty) {
log('No notifications to mark as read');
return;
}
log('Marking ${unread.length} notifications as read');
await _datasource.markAllAsRead(
_auth.state.requireData[Webservice.lb_planner_api],
unread,
);
emit(
AsyncValue.data(
state.requireData.map((e) => e.copyWith(read: true)).toList(),
),
);
log('All notifications marked as read');
await captureEvent('notifications_read');
}