Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class NotificationRemoteDataSource {
Future<List<Notification>> getAllNotifications(
{DateTime? syncedSince, bool? noClientId});
Future<Notification?> getNotification(int id);
Future<Notification> markAsRead(int id, DateTime readAt);
Future<Notification> markAsRead(int id, DateTime readAt, {String? clientId});
}

@Injectable(as: NotificationRemoteDataSource)
Expand Down Expand Up @@ -71,11 +71,13 @@ class NotificationRemoteDataSourceImpl implements NotificationRemoteDataSource {
}

@override
Future<Notification> markAsRead(int id, DateTime readAt) async {
final response = await dio.put(
Future<Notification> markAsRead(int id, DateTime readAt,
{String? clientId}) async {
final response = await dio.post(
'notifications/$id/read',
data: {
'read_at': formatServerIsoDateTimeString(readAt),
if (clientId != null && clientId.isNotEmpty) 'client_id': clientId,
},
);

Expand Down
6 changes: 5 additions & 1 deletion lib/data/sync/notification_sync_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ class NotificationSyncHandler extends SyncTypeHandler<Notification, String, int>
// For notifications, we typically don't create/update from client
// But if read_at is updated, we need to sync it
if (entity.readAt != null && entity.id != null) {
return await remoteDataSource.markAsRead(entity.id!, entity.readAt!);
return await remoteDataSource.markAsRead(
entity.id!,
entity.readAt!,
clientId: entity.clientId,
);
}
return entity;
}
Expand Down
Loading