aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Views/MessageBoardView.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2023-12-11 23:32:28 -0800
committerDustin Mierau <dustin@mierau.me>2023-12-11 23:32:28 -0800
commit18c4b8643df09be4ce52a4b110ea21ac1ad053fc (patch)
tree335d4f0a6b430b983b6f00567b91eb1ee6b16b4b /Hotline/Views/MessageBoardView.swift
parent84aaa9ef0a1be6986e38d7e4f58e07d3cb84979e (diff)
Move to new Hotline model for data observation and let client exist standalone.
Diffstat (limited to 'Hotline/Views/MessageBoardView.swift')
-rw-r--r--Hotline/Views/MessageBoardView.swift27
1 files changed, 16 insertions, 11 deletions
diff --git a/Hotline/Views/MessageBoardView.swift b/Hotline/Views/MessageBoardView.swift
index 04f51df..473162e 100644
--- a/Hotline/Views/MessageBoardView.swift
+++ b/Hotline/Views/MessageBoardView.swift
@@ -1,8 +1,9 @@
import SwiftUI
struct MessageBoardView: View {
- @Environment(HotlineState.self) private var appState
- @Environment(HotlineClient.self) private var hotline
+ @Environment(Hotline.self) private var model: Hotline
+// @Environment(HotlineState.self) private var appState
+// @Environment(HotlineClient.self) private var hotline
@State private var fetched = false
@@ -11,7 +12,7 @@ struct MessageBoardView: View {
NavigationStack {
ScrollView {
LazyVStack(alignment: .leading) {
- ForEach(hotline.messageBoardMessages, id: \.self) {
+ ForEach(model.messageBoard, id: \.self) {
Text($0)
.lineLimit(100)
.padding()
@@ -23,23 +24,26 @@ struct MessageBoardView: View {
}
.task {
if !fetched {
- hotline.sendGetMessageBoard() {
- fetched = true
- }
+ let _ = await model.getMessageBoard()
+// hotline.sendGetMessageBoard() {
+ fetched = true
+// }
}
}
.refreshable {
- hotline.sendGetMessageBoard()
+ let _ = await model.getMessageBoard()
+// hotline.sendGetMessageBoard()
}
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
- Text(hotline.server?.name ?? "")
+ Text(model.server?.name ?? "")
.font(.headline)
}
ToolbarItem(placement: .navigationBarLeading) {
Button {
- hotline.disconnect()
+ model.disconnect()
+// hotline.disconnect()
} label: {
Text(Image(systemName: "xmark.circle.fill"))
.symbolRenderingMode(.hierarchical)
@@ -65,6 +69,7 @@ struct MessageBoardView: View {
#Preview {
MessageBoardView()
- .environment(HotlineState())
- .environment(HotlineClient())
+ .environment(Hotline(trackerClient: HotlineTrackerClient(), client: HotlineNewClient()))
+// .environment(HotlineState())
+// .environment(HotlineClient())
}