read method

  1. @override
void read(
  1. ServerNotificationModel notification
)
override

Implementation

@override
void read(ServerNotificationModel notification) async {
  if (currentServerNotificationData == null) return;
  await notificationCenterDataSource.read(notification.uuid);
  final oldResponse = currentServerNotificationData!.data;
  final newData = oldResponse.data
      .map(
        (element) => element.uuid == notification.uuid
            ? element.copyWith(readAt: DateTime.now())
            : element,
      )
      .toList();
  final newResponse = oldResponse.copyWith(data: newData);
  final newServerNotificationData = ServerNotificationData(
    type: SeverNotificationChangedType.loaded,
    data: newResponse,
  );
  serverNotificationStreamController.add(newServerNotificationData);
  currentServerNotificationData = newServerNotificationData;
}