fixed the count of users not working and adding the timer, but still a little buggy
This commit is contained in:
@@ -11,9 +11,11 @@ struct ConvoFooterView: View {
|
|||||||
@EnvironmentObject var convoVM: ConvoViewModel
|
@EnvironmentObject var convoVM: ConvoViewModel
|
||||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||||
|
|
||||||
@State private var convoRelativeTime = "started 20 minutes ago"
|
@State private var convoRelativeTime = ""
|
||||||
@State private var selectedConvo: Convo? = nil
|
@State private var selectedConvo: Convo? = nil
|
||||||
|
|
||||||
|
let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
||||||
ZStack(alignment:.bottomTrailing) {
|
ZStack(alignment:.bottomTrailing) {
|
||||||
@@ -22,6 +24,11 @@ struct ConvoFooterView: View {
|
|||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
if self.selectedConvo != nil {
|
if self.selectedConvo != nil {
|
||||||
|
// TODO: get their info for warm intros to be made
|
||||||
|
// var unknownUsers = self.selectedConvo!.users.filter {userId in
|
||||||
|
// return !self.authSessionStore.relevantUsersDict.keys.contains(userId)
|
||||||
|
// }
|
||||||
|
// the users which I have data for
|
||||||
let filteredUsers = self.authSessionStore.relevantUsersDict.filter {
|
let filteredUsers = self.authSessionStore.relevantUsersDict.filter {
|
||||||
return self.selectedConvo!.users.contains($0.key)
|
return self.selectedConvo!.users.contains($0.key)
|
||||||
}
|
}
|
||||||
@@ -33,7 +40,7 @@ struct ConvoFooterView: View {
|
|||||||
|
|
||||||
// meta data of convo
|
// meta data of convo
|
||||||
VStack (alignment: .leading) {
|
VStack (alignment: .leading) {
|
||||||
ConvoUsernames(users: convoUsers)
|
ConvoUsernames(users: convoUsers, unknownUserCount: self.selectedConvo!.users.count - convoUsers.count)
|
||||||
|
|
||||||
switch self.convoVM.connectionState {
|
switch self.convoVM.connectionState {
|
||||||
case .connecting:
|
case .connecting:
|
||||||
@@ -119,17 +126,17 @@ struct ConvoFooterView: View {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the selected options to start fresh
|
|
||||||
self.convoRelativeTime = ""
|
|
||||||
|
|
||||||
self.selectedConvo = newConvos.first {convo in
|
self.selectedConvo = newConvos.first {convo in
|
||||||
convo.id == self.convoVM.selectedConvoId
|
convo.id == self.convoVM.selectedConvoId
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// get relative start time of convo
|
.onReceive(timer) { _ in
|
||||||
let formatter = RelativeDateTimeFormatter()
|
if self.selectedConvo != nil {
|
||||||
formatter.unitsStyle = .full
|
// get relative start time of convo
|
||||||
self.convoRelativeTime = formatter.localizedString(for: self.selectedConvo?.startedTimestamp ?? Date(), relativeTo: Date())
|
let formatter = RelativeDateTimeFormatter()
|
||||||
|
formatter.unitsStyle = .full
|
||||||
|
self.convoRelativeTime = "started " + formatter.localizedString(for: self.selectedConvo?.startedTimestamp ?? Date(), relativeTo: Date())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,10 +149,11 @@ struct ConvoFooterView_Previews: PreviewProvider {
|
|||||||
|
|
||||||
struct ConvoUsernames: View {
|
struct ConvoUsernames: View {
|
||||||
var users: [User]
|
var users: [User]
|
||||||
|
var unknownUserCount: Int = 0
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let userNames = self.users.map{$0.nickname ?? ""}.joined(separator: ",")
|
let userNames = self.users.map{$0.nickname ?? ""}.joined(separator: ", ")
|
||||||
Text(userNames)
|
Text(unknownUserCount > 0 ? "\(userNames), and \(unknownUserCount) other(s)": userNames)
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.foregroundColor(NirvanaColor.light)
|
.foregroundColor(NirvanaColor.light)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ struct CircleGridView: View {
|
|||||||
.font(.title2)
|
.font(.title2)
|
||||||
.padding(5)
|
.padding(5)
|
||||||
.overlay(
|
.overlay(
|
||||||
Text("\(convoUsers.count)")
|
Text("\(currConvo.users.count)")
|
||||||
.foregroundColor(Color.white)
|
.foregroundColor(Color.white)
|
||||||
.font(.caption2)
|
.font(.caption2)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user