mirror of https://github.com/lukechilds/damus.git
Browse Source
Changelog-Changed: Show recommended relays in config. Currently just a fixed set.post-button-style
William Casarin
2 years ago
7 changed files with 101 additions and 46 deletions
@ -0,0 +1,37 @@ |
|||
// |
|||
// RecommendedRelayView.swift |
|||
// damus |
|||
// |
|||
// Created by William Casarin on 2022-12-29. |
|||
// |
|||
|
|||
import SwiftUI |
|||
|
|||
struct RecommendedRelayView: View { |
|||
let damus: DamusState |
|||
let relay: String |
|||
|
|||
var body: some View { |
|||
HStack { |
|||
Text(relay) |
|||
Spacer() |
|||
if let ev = damus.contacts.event { |
|||
if let privkey = damus.keypair.privkey { |
|||
Button("Add") { |
|||
guard let ev = add_relay(ev: ev, privkey: privkey, current_relays: damus.pool.descriptors, relay: relay, info: .rw) else { |
|||
return |
|||
} |
|||
process_contact_event(pool: damus.pool, contacts: damus.contacts, pubkey: damus.pubkey, ev: ev) |
|||
damus.pool.send(.event(ev)) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
struct RecommendedRelayView_Previews: PreviewProvider { |
|||
static var previews: some View { |
|||
RecommendedRelayView(damus: test_damus_state(), relay: "wss://relay.damus.io") |
|||
} |
|||
} |
Loading…
Reference in new issue