markAsRead method
Implementation
Future<void> markAsRead(EnhancedRoomModel room, ChatModel item) async {
var roomId = room.roomModel.documentID;
if ((room.timeStampThisMemberRead == null) ||
(item.timestamp != null) &&
(item.timestamp!.compareTo(room.timeStampThisMemberRead!) > 0)) {
try {
await chatMemberInfoRepository(
appId: room.roomModel.appId, roomId: roomId)!
.add(ChatMemberInfoModel(
appId: room.roomModel.appId,
documentID: RoomHelper.getChatMemberInfoId(thisMemberId, roomId),
authorId: thisMemberId,
roomId: roomId,
accessibleByGroup: ChatMemberInfoAccessibleByGroup.specificMembers,
accessibleByMembers: room.roomModel.members,
readAccess: [
thisMemberId
], // default readAccess to the owner. The function will expand this based on accessibleByGroup/Members
));
} catch (_) {
// issue with timestamp: ignore
}
}
}