aboutsummaryrefslogtreecommitdiff
path: root/Hotline
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2024-07-26 21:52:20 -0700
committerDustin Mierau <dustin@mierau.me>2024-07-26 21:52:20 -0700
commit5726ab32f161e4b62ee0d65303b76d9894769c92 (patch)
tree2558f498b48045d9bdf95177c8087b2da4f3db67 /Hotline
parente7725f97178fdf269973018114e2c5a4f0241251 (diff)
Added support for announce in chat, hold shift while pressing enter to send chat.
Diffstat (limited to 'Hotline')
-rw-r--r--Hotline/Hotline/HotlineClient.swift3
-rw-r--r--Hotline/Models/Hotline.swift4
-rw-r--r--Hotline/macOS/ChatView.swift3
3 files changed, 5 insertions, 5 deletions
diff --git a/Hotline/Hotline/HotlineClient.swift b/Hotline/Hotline/HotlineClient.swift
index a151357..434285f 100644
--- a/Hotline/Hotline/HotlineClient.swift
+++ b/Hotline/Hotline/HotlineClient.swift
@@ -455,9 +455,10 @@ class HotlineClient: NetSocketDelegate {
self.sendPacket(t)
}
- @MainActor func sendChat(message: String, encoding: String.Encoding = .utf8) {
+ @MainActor func sendChat(message: String, encoding: String.Encoding = .utf8, announce: Bool = false) {
var t = HotlineTransaction(type: .sendChat)
t.setFieldString(type: .data, val: message, encoding: encoding)
+ t.setFieldUInt16(type: .chatOptions, val: announce ? 1 : 0)
self.sendPacket(t)
}
diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift
index 11781c7..30d2ef5 100644
--- a/Hotline/Models/Hotline.swift
+++ b/Hotline/Models/Hotline.swift
@@ -244,8 +244,8 @@ class Hotline: Equatable, HotlineClientDelegate, HotlineFileDownloadClientDelega
self.unreadInstantMessages.removeValue(forKey: userID)
}
- @MainActor func sendChat(_ text: String) {
- self.client.sendChat(message: text)
+ @MainActor func sendChat(_ text: String, announce: Bool = false) {
+ self.client.sendChat(message: text, announce: announce)
}
@MainActor func getMessageBoard() async -> [String] {
diff --git a/Hotline/macOS/ChatView.swift b/Hotline/macOS/ChatView.swift
index b7b92d6..cd84369 100644
--- a/Hotline/macOS/ChatView.swift
+++ b/Hotline/macOS/ChatView.swift
@@ -148,10 +148,9 @@ struct ChatView: View {
.textFieldStyle(.plain)
.lineLimit(1...5)
.multilineTextAlignment(.leading)
- // .frame(maxWidth: .infinity)
.onSubmit {
if !self.input.isEmpty {
- model.sendChat(self.input)
+ model.sendChat(self.input, announce: NSEvent.modifierFlags.contains(.shift))
}
self.input = ""
}