From 5726ab32f161e4b62ee0d65303b76d9894769c92 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Fri, 26 Jul 2024 21:52:20 -0700 Subject: Added support for announce in chat, hold shift while pressing enter to send chat. --- Hotline/Hotline/HotlineClient.swift | 3 ++- Hotline/Models/Hotline.swift | 4 ++-- Hotline/macOS/ChatView.swift | 3 +-- 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 = "" } -- cgit