filteredNotificationsByDateFamily top-level property
final
Provides a mapping of dates to filtered app notifications
Implementation
final filteredNotificationsByDateFamily = Provider.autoDispose
.family<AsyncValue<Map<DateTime?, List<AppNotification>>>, String>(
(ref, String filterText) {
final notifications = ref.watch(filteredNotificationsFamily(filterText));
final notificationTimestampUseCase =
ref.watch(notificationTimestampUseCaseProvider);
List<AppNotification> sortedNotifications(
List<AppNotification> notifications,
) {
return notifications.sortedByCompare(
(notification) => notification.timestamp,
_mostRecentDate,
);
}
return notifications.mapValue(
(value) => Map.fromEntries(
value
.groupListsBy(notificationTimestampUseCase)
.map((key, value) => MapEntry(key, sortedNotifications(value)))
.entries
.sortedByCompare((entry) => entry.key, _mostRecentDate),
),
);
},
);