trying to get only messages with listen count not high
This commit is contained in:
@@ -108,8 +108,6 @@ class FirestoreService {
|
|||||||
return FieldValue.serverTimestamp()
|
return FieldValue.serverTimestamp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func createOrUpdateUserFriends(userFriend: UserFriends, completion: @escaping((_ state: ServiceState) -> ())) {
|
func createOrUpdateUserFriends(userFriend: UserFriends, completion: @escaping((_ state: ServiceState) -> ())) {
|
||||||
do {
|
do {
|
||||||
let userFriendCollection = db.collection(Collection.userFriends.rawValue)
|
let userFriendCollection = db.collection(Collection.userFriends.rawValue)
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ extension AuthSessionStore {
|
|||||||
// order: sent time should make it easy to add to dict
|
// order: sent time should make it easy to add to dict
|
||||||
// limit: because each user should have most 12 friends and so would at most need 24 messages to show turns and all that...save myself from hackers here
|
// limit: because each user should have most 12 friends and so would at most need 24 messages to show turns and all that...save myself from hackers here
|
||||||
// TODO: use the indexes I created
|
// TODO: use the indexes I created
|
||||||
db.collection("messages").whereField("receiverId", isEqualTo: userId).limit(to: 100)
|
db.collection("messages").whereField("receiverId", isEqualTo: userId).whereField("listenCount", isLessThanOrEqualTo: 1).limit(to: 100)
|
||||||
.addSnapshotListener { querySnapshot, error in
|
.addSnapshotListener { querySnapshot, error in
|
||||||
guard let documents = querySnapshot?.documents else {
|
guard let documents = querySnapshot?.documents else {
|
||||||
print("Error fetching messages: \(error!)")
|
print("Error fetching messages: \(error!)")
|
||||||
|
|||||||
Reference in New Issue
Block a user