From 3049bfad969efd89018e0d4ad4e77c24812b559c Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 2 Jan 2022 19:58:56 -0800 Subject: [PATCH] retaining order of friends with a new database index and fixing the order right from the db to avoid frontend processing && blurring things nicely when recording to a friend --- nirvana-ios/Services/AuthSessionStore.swift | 4 +-- .../Views/InnerCircle/CircleGridView.swift | 25 ++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/nirvana-ios/Services/AuthSessionStore.swift b/nirvana-ios/Services/AuthSessionStore.swift index fcb269f..8a5b2ee 100644 --- a/nirvana-ios/Services/AuthSessionStore.swift +++ b/nirvana-ios/Services/AuthSessionStore.swift @@ -238,7 +238,7 @@ extension AuthSessionStore { // MARK: keeping the friends list updated // TODO: break into firestoreService metadata of each change...later tho since this listener will barely get changes - let friendsListener = db.collection("user_friends").whereField("userId", isEqualTo: currUserId).limit(to: 100) + let friendsListener = db.collection("user_friends").whereField("userId", isEqualTo: currUserId).order(by: "createdTimestamp", descending: false) .addSnapshotListener { querySnapshot, error in print("friends listener activated") @@ -297,7 +297,7 @@ extension AuthSessionStore { // update current friendsArr if the friend is already there if let indexFriend = self.friendsArr.firstIndex(of: userFriend!.friendId) { - print("friend already in the friends arr, just needed to update the relevantusersdict") + print("friend already in the friends arr, prolly just a change to the friends status or profile") } else { // new friend not in array self.friendsArr.append(userFriend!.friendId) } diff --git a/nirvana-ios/Views/InnerCircle/CircleGridView.swift b/nirvana-ios/Views/InnerCircle/CircleGridView.swift index a1f94cc..b1bfb6d 100644 --- a/nirvana-ios/Views/InnerCircle/CircleGridView.swift +++ b/nirvana-ios/Views/InnerCircle/CircleGridView.swift @@ -174,7 +174,8 @@ struct CircleGridView: View { x: honeycombOffSetX(adjustedValue), y: 0 ) - .id(friendId) // id for scrollviewreader + .blur(radius: self.getBlur(friendDbId: friendId)) + .id(friendId) // id for scrollviewreader TODO: not forcing an update if we add another friend...problem with the grid changing .frame(height: Self.size) .simultaneousGesture( TapGesture() @@ -386,6 +387,22 @@ struct CircleGridView: View { return false } + /** + dynamic blur control based on if we are recording to a particular friend or not + */ + private func getBlur(friendDbId: String) -> CGFloat { + // if we have selected this user and we are recording currently, then don't want to blur this one at all + if self.selectedFriendIndex == friendDbId { + return 0 + } + // if recording, and have someone selected, then want to blur everyone else + else if self.innerCircleVM.isRecording && friendDbId != self.selectedFriendIndex { + return 8 + } + + return 0 + } + private func getBubbleTint(friendDbId: String) -> Color { // TODO: check if I listened to the message before or not if self.haveNewMessageFromFriend(friendDbId: friendDbId) { // this friend has a message for me @@ -423,6 +440,12 @@ extension CircleGridView { private func getScale(proxy: GeometryProxy, itemNumber: Int, userId: String? = nil, convoId: String? = nil) -> CGFloat { // if this user is selected if userId != nil && userId == self.selectedFriendIndex { + + // make it even bigger if we are recording + if self.innerCircleVM.isRecording { + return big + 1 + } + return big + 0.2 }