Files
damus/damus/Views/Relays/RelayStatusView.swift
T
Daniel D’Aquino 3a0acfaba1 Implement NostrNetworkManager and UserRelayListManager
This commit implements a new layer called NostrNetworkManager,
responsible for managing interactions with the Nostr network, and
providing a higher level API that is easier and more secure to use for
the layer above it.

It also integrates it with the rest of the app, by moving RelayPool and PostBox
into NostrNetworkManager, along with all their usages.

Changelog-Added: Added NIP-65 relay list support
Changelog-Changed: Improved robustness of relay list handling
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-04-16 11:48:52 -07:00

63 lines
2.4 KiB
Swift

//
// RelayStatusView.swift
// damus
//
// Created by William Casarin on 2023-02-10.
//
import SwiftUI
struct RelayStatusView: View {
@ObservedObject var connection: RelayConnection
var body: some View {
Group {
if connection.isConnecting {
Text("Connecting", comment: "Relay status label that indicates a relay is connecting.")
.font(.caption)
.frame(height: 20)
.padding(.horizontal, 10)
.foregroundColor(DamusColors.warning)
.background(DamusColors.warningQuaternary)
.cornerRadius(20)
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(DamusColors.warningBorder, lineWidth: 1)
)
} else if connection.isConnected {
Text("Online", comment: "Relay status label that indicates a relay is connected.")
.font(.caption)
.frame(height: 20)
.padding(.horizontal, 10)
.foregroundColor(DamusColors.success)
.background(DamusColors.successQuaternary)
.cornerRadius(20)
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(DamusColors.successBorder, lineWidth: 1)
)
} else {
Text("Error", comment: "Relay status label that indicates a relay had an error when connecting")
.font(.caption)
.frame(height: 20)
.padding(.horizontal, 10)
.foregroundColor(DamusColors.danger)
.background(DamusColors.dangerQuaternary)
.border(DamusColors.dangerBorder)
.cornerRadius(20)
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(DamusColors.dangerBorder, lineWidth: 1)
)
}
}
}
}
struct RelayStatusView_Previews: PreviewProvider {
static var previews: some View {
let connection = test_damus_state.nostrNetwork.pool.get_relay(RelayURL("wss://relay.damus.io")!)!.connection
RelayStatusView(connection: connection)
}
}