aboutsummaryrefslogtreecommitdiff
path: root/Hotline/macOS/MessageBoardView.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2024-01-15 20:20:47 -0800
committerDustin Mierau <dustin@mierau.me>2024-01-15 20:20:47 -0800
commit7c9f6686044035c022a17551151cf1cbed0dc665 (patch)
treed41403b6f64d3375fdea8cee48d9db91c3ce26e0 /Hotline/macOS/MessageBoardView.swift
parentfaae9cd1b47c6f22f3bcf4b1a24a4f7df41af9ed (diff)
Add classic sound effects. Fix read user access bits. Better no content/no access views. Add Server menu. Add keep alive ping to server every 3 minutes.
Diffstat (limited to 'Hotline/macOS/MessageBoardView.swift')
-rw-r--r--Hotline/macOS/MessageBoardView.swift68
1 files changed, 46 insertions, 22 deletions
diff --git a/Hotline/macOS/MessageBoardView.swift b/Hotline/macOS/MessageBoardView.swift
index e7fdeb5..27b4be7 100644
--- a/Hotline/macOS/MessageBoardView.swift
+++ b/Hotline/macOS/MessageBoardView.swift
@@ -9,34 +9,51 @@ struct MessageBoardView: View {
var body: some View {
NavigationStack {
- ScrollView {
- LazyVStack(alignment: .leading) {
- ForEach(model.messageBoard, id: \.self) {
- Text($0)
- .lineLimit(100)
- .lineSpacing(4)
- .padding()
- .textSelection(.enabled)
- Divider()
+ if model.access?.contains(.canReadMessageBoard) != false {
+ ScrollView {
+ LazyVStack(alignment: .leading) {
+ ForEach(model.messageBoard, id: \.self) {
+ Text($0)
+ .lineLimit(100)
+ .lineSpacing(4)
+ .padding()
+ .textSelection(.enabled)
+ Divider()
+ }
}
+ Spacer()
}
- Spacer()
- }
- .task {
- if !model.messageBoardLoaded {
- let _ = await model.getMessageBoard()
+ .task {
+ if !model.messageBoardLoaded {
+ let _ = await model.getMessageBoard()
+ }
}
- }
- .overlay {
- if !model.messageBoardLoaded {
- VStack {
- ProgressView()
- .controlSize(.large)
+ .overlay {
+ if !model.messageBoardLoaded {
+ VStack {
+ ProgressView()
+ .controlSize(.large)
+ }
+ .frame(maxWidth: .infinity)
}
- .frame(maxWidth: .infinity)
}
+ .background(Color(nsColor: .textBackgroundColor))
+ }
+ else {
+ VStack {
+ Text("No Message Board")
+ .bold()
+ .foregroundStyle(.secondary)
+ .font(.title3)
+ Text("This server has the message board turned off.")
+ .foregroundStyle(.tertiary)
+ .font(.system(size: 13))
+ }
+ .padding()
}
- .background(Color(nsColor: .textBackgroundColor))
+
+
+
}
.sheet(isPresented: $composerDisplayed) {
TextEditor(text: $composerText)
@@ -65,6 +82,11 @@ struct MessageBoardView: View {
}
}
}
+// .alert("Hello", isPresented: $showPermissionAlert) {
+// Button("OK") {
+// showPermissionAlert.toggle()
+// }
+// } message: { Text("WHAT") }
.toolbar {
ToolbarItem(placement:.primaryAction) {
Button {
@@ -72,6 +94,8 @@ struct MessageBoardView: View {
} label: {
Image(systemName: "square.and.pencil")
}
+ .disabled(model.access?.contains(.canPostMessageBoard) == false)
+ .help("Post to Message Board")
}
}
}