damus

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

commit 40468b16036a41a493e1f9a01f30c5ecd9bbbc6f
parent 8c19ec1532b9c8489b7922547fea5834024ac69a
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 14 Apr 2023 10:17:24 -0700

refactor: dms view init logic

Diffstat:
Mdamus/ContentView.swift | 1-
Mdamus/Views/DirectMessagesView.swift | 11+++++------
2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/damus/ContentView.swift b/damus/ContentView.swift @@ -185,7 +185,6 @@ struct ContentView: View { case .dms: DirectMessagesView(damus_state: damus_state!) - .environmentObject(home.dms) case .none: EmptyView() diff --git a/damus/Views/DirectMessagesView.swift b/damus/Views/DirectMessagesView.swift @@ -17,13 +17,14 @@ struct DirectMessagesView: View { @State var dm_type: DMType = .friend @State var open_dm: Bool = false - @State var pubkey: String = "" - @EnvironmentObject var model: DirectMessagesModel - @State var active_model: DirectMessageModel + @State var pubkey: String + @ObservedObject var model: DirectMessagesModel + @State var active_model: DirectMessageModel = DirectMessageModel(our_pubkey: "") init(damus_state: DamusState) { self.damus_state = damus_state - self._active_model = State(initialValue: DirectMessageModel(our_pubkey: damus_state.pubkey)) + self._model = ObservedObject(initialValue: damus_state.dms) + self.pubkey = damus_state.pubkey } func MainContent(requests: Bool) -> some View { @@ -106,8 +107,6 @@ struct DirectMessagesView_Previews: PreviewProvider { kind: 4, tags: []) let ds = test_damus_state() - let model = DirectMessageModel(events: [ev], our_pubkey: ds.pubkey) DirectMessagesView(damus_state: ds) - .environmentObject(model) } }