loading indicator

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-04-18 16:35:18 -07:00
parent f2265153fa
commit 914520205e
2 changed files with 13 additions and 7 deletions

View File

@@ -95,7 +95,12 @@ struct ContentView: View {
var body: some View {
NavigationView {
VStack {
TopBar(selected: self.timeline)
if self.loading {
ProgressView()
.progressViewStyle(.circular)
.padding([.bottom], 4)
}
ZStack {
if let pool = self.pool {
MainContent(pool: pool)
@@ -103,6 +108,7 @@ struct ContentView: View {
}
PostButtonContainer
}
TopBar(selected: self.timeline ?? .friends)
}
.navigationBarTitle("Damus", displayMode: .inline)
}
@@ -220,14 +226,14 @@ struct ContentView: View {
switch ev {
case .connected:
self.loading = ((self.pool?.num_connecting ?? 0) > 0)
send_filters(relay_id: relay_id)
case .error(let merr):
let desc = merr.debugDescription
if desc.contains("Software caused connection abort") {
self.pool?.reconnect(to: [relay_id])
}
case .disconnected:
self.pool?.reconnect(to: [relay_id])
case .disconnected: fallthrough
case .cancelled:
self.pool?.reconnect(to: [relay_id])
case .reconnectSuggested(let t):
@@ -248,10 +254,6 @@ struct ContentView: View {
return
}
if self.loading {
self.loading = false
}
if has_events[ev.id] == nil {
has_events[ev.id] = ()
let last_k = last_event_of_kind[ev.kind]