fixed: relay detail view is not immediately available after adding new relay
Changelog-Fixed: relay detail view is not immediately available after adding new relay Closes: https://github.com/damus-io/damus/issues/1369 Signed-off-by: Bryan Montz <bryanmontz@me.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
47e7505573
commit
45ab394b09
@@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
final class RelayModelCache {
|
||||
final class RelayModelCache: ObservableObject {
|
||||
private var models = [RelayURL: RelayModel]()
|
||||
|
||||
func model(withURL url: RelayURL) -> RelayModel? {
|
||||
@@ -23,5 +23,6 @@ final class RelayModelCache {
|
||||
|
||||
func insert(model: RelayModel) {
|
||||
models[model.url] = model
|
||||
objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,17 @@ import SwiftUI
|
||||
struct RelayView: View {
|
||||
let state: DamusState
|
||||
let relay: String
|
||||
@ObservedObject private var model_cache: RelayModelCache
|
||||
|
||||
@Binding var showActionButtons: Bool
|
||||
|
||||
init(state: DamusState, relay: String, showActionButtons: Binding<Bool>) {
|
||||
self.state = state
|
||||
self.relay = relay
|
||||
self.model_cache = state.relay_model_cache
|
||||
_showActionButtons = showActionButtons
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
HStack {
|
||||
@@ -27,7 +35,7 @@ struct RelayView: View {
|
||||
|
||||
RelayType(is_paid: state.relay_model_cache.model(with_relay_id: relay)?.metadata.is_paid ?? false)
|
||||
|
||||
if let meta = state.relay_model_cache.model(with_relay_id: relay)?.metadata {
|
||||
if let meta = model_cache.model(with_relay_id: relay)?.metadata {
|
||||
Text(relay)
|
||||
.background(
|
||||
NavigationLink(value: Route.RelayDetail(relay: relay, metadata: meta), label: {
|
||||
|
||||
Reference in New Issue
Block a user