Show paid or global relay type next to relay status
Changelog-Added: Show if relay is paid
This commit is contained in:
@@ -11,45 +11,22 @@ struct RelayView: View {
|
||||
let state: DamusState
|
||||
let relay: String
|
||||
|
||||
let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect()
|
||||
@State var conn_color: Color = .gray
|
||||
|
||||
func update_connection_color() {
|
||||
for relay in state.pool.relays {
|
||||
if relay.id == self.relay {
|
||||
let c = relay.connection
|
||||
if c.isConnected {
|
||||
conn_color = .green
|
||||
} else if c.isConnecting || c.isReconnecting {
|
||||
conn_color = .yellow
|
||||
} else {
|
||||
conn_color = .red
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Circle()
|
||||
.frame(width: 8.0, height: 8.0)
|
||||
.foregroundColor(conn_color)
|
||||
if let meta = state.relay_metadata.lookup(relay_id: relay) {
|
||||
NavigationLink {
|
||||
RelayDetailView(state: state, relay: relay, nip11: meta, conn_color: conn_color)
|
||||
} label: {
|
||||
Group {
|
||||
HStack {
|
||||
RelayStatus(pool: state.pool, relay: relay)
|
||||
RelayType(is_paid: state.relay_metadata.lookup(relay_id: relay)?.is_paid ?? false)
|
||||
if let meta = state.relay_metadata.lookup(relay_id: relay) {
|
||||
NavigationLink {
|
||||
RelayDetailView(state: state, relay: relay, nip11: meta)
|
||||
} label: {
|
||||
Text(relay)
|
||||
}
|
||||
} else {
|
||||
Text(relay)
|
||||
}
|
||||
} else {
|
||||
Text(relay)
|
||||
}
|
||||
}
|
||||
.onReceive(timer) { _ in
|
||||
update_connection_color()
|
||||
}
|
||||
.onAppear() {
|
||||
update_connection_color()
|
||||
}
|
||||
.swipeActions {
|
||||
if let privkey = state.keypair.privkey {
|
||||
RemoveAction(privkey: privkey)
|
||||
@@ -94,6 +71,6 @@ struct RelayView: View {
|
||||
|
||||
struct RelayView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
RelayView(state: test_damus_state(), relay: "wss://relay.damus.io", conn_color: .red)
|
||||
RelayView(state: test_damus_state(), relay: "wss://relay.damus.io")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user