This commit is contained in:
spaced4ndy
2024-06-26 14:08:31 +04:00
parent 46bc947128
commit 2457fa174e
2 changed files with 34 additions and 14 deletions
@@ -20,7 +20,6 @@ struct ChatListView: View {
@State private var newChatMenuOption: NewChatMenuOption? = nil
@State private var userPickerVisible = false
@State private var showConnectDesktop = false
@State private var showServersSummary = false
@AppStorage(DEFAULT_SHOW_UNREAD_AND_FAVORITES) private var showUnreadAndFavorites = false
var body: some View {
@@ -63,9 +62,6 @@ struct ChatListView: View {
.sheet(isPresented: $showConnectDesktop) {
ConnectDesktopView()
}
.sheet(isPresented: $showServersSummary) {
ServersSummaryView()
}
}
private var chatListView: some View {
@@ -119,7 +115,7 @@ struct ChatListView: View {
HStack(spacing: 4) {
Text("Chats")
.font(.headline)
subscriptionsStatusIcon()
SubsStatusIndicator()
}
.frame(maxWidth: .infinity, alignment: .center)
}
@@ -133,15 +129,6 @@ struct ChatListView: View {
}
}
private func subscriptionsStatusIcon() -> some View {
Button {
showServersSummary = true
} label: {
// TODO backend to periodically send updates to model
SubscriptionStatusView(activeSubs: 100, pendingSubs: 0)
}
}
@ViewBuilder private var chatList: some View {
let cs = filteredChats()
ZStack {
@@ -276,6 +263,34 @@ struct ChatListView: View {
}
}
struct SubsStatusIndicator: View {
@State private var subs: SMPServerSubs = SMPServerSubs(ssActive: 0, ssPending: 0)
@State private var showServersSummary = false
var body: some View {
Button {
showServersSummary = true
} label: {
SubscriptionStatusView(activeSubs: subs.ssActive, pendingSubs: subs.ssPending)
}
.onAppear {
// TODO update
getSubsSummary()
}
.sheet(isPresented: $showServersSummary) {
ServersSummaryView()
}
}
private func getSubsSummary() {
do {
subs = try getAgentSubsSummary()
} catch let error {
logger.error("getAgentSubsSummary error: \(responseError(error))")
}
}
}
struct ChatListSearchBar: View {
@EnvironmentObject var m: ChatModel
@Binding var searchMode: Bool
+5
View File
@@ -2297,6 +2297,11 @@ public struct ServerSessions: Codable {
public struct SMPServerSubs: Codable {
public var ssActive: Int
public var ssPending: Int
public init(ssActive: Int, ssPending: Int) {
self.ssActive = ssActive
self.ssPending = ssPending
}
}
public struct AgentSMPServerStatsData: Codable {