changeSeenStatus method
Implementation
Future<void> changeSeenStatus(String? userId, String? path, int seenStatus) async {
if (path != null)
return _firestoreRepository.firestore.runTransaction((transaction) async {
var documentReference = _firestoreRepository.doc(path);
DocumentSnapshot<Map<String, dynamic>> txSnapshot = await transaction.get(documentReference);
if (!txSnapshot.exists) return;
var json = txSnapshot.data() as Map<String, Object?>;
if (userId != null) {
if (json["seenBy"] == null) json["seenBy"] = [];
(json["seenBy"] as List).add(userId);
}
json["seenStatus"] = seenStatus;
transaction.update(documentReference, json);
});
// .catchError((e) {
// return false;
// });
}