damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | LICENSE

commit 914520205e40a1d4509ba8872f13c40ed5895c13
parent f2265153fac51c98889be6e7121b0a3278cdda13
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 18 Apr 2022 16:35:18 -0700

loading indicator

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/ContentView.swift | 16+++++++++-------
Mdamus/Nostr/RelayPool.swift | 4++++
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/damus/ContentView.swift b/damus/ContentView.swift @@ -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] diff --git a/damus/Nostr/RelayPool.swift b/damus/Nostr/RelayPool.swift @@ -35,6 +35,10 @@ class RelayPool { var descriptors: [RelayDescriptor] { relays.map { $0.descriptor } } + + var num_connecting: Int { + return relays.reduce(0) { n, r in n + (r.connection.isConnecting ? 1 : 0) } + } func remove_handler(sub_id: String) { handlers = handlers.filter { $0.sub_id != sub_id }