aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2024-04-20 22:19:42 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2024-04-20 22:19:42 -0700
commit3934a0487ad80f231e4088902bf8308c12c2d0b0 (patch)
tree846ebd450292db1309e79bdef20b2c17692eafdc /Hotline/Models
parent1a82975ad00bced8bba8cd6df6a9920a7ae93c61 (diff)
Add handling for new news post transaction
Diffstat (limited to 'Hotline/Models')
-rw-r--r--Hotline/Models/Hotline.swift13
1 files changed, 13 insertions, 0 deletions
diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift
index 6b5e3a7..baf87eb 100644
--- a/Hotline/Models/Hotline.swift
+++ b/Hotline/Models/Hotline.swift
@@ -649,6 +649,19 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate {
func hotlineReceivedAgreement(text: String) {
self.chat.append(ChatMessage(text: text, type: .agreement, date: Date()))
}
+
+ func hotlineReceivedNewsPost(message: String) {
+ soundEffects.playSoundEffect(.newNews)
+ let messageBoardRegex = /([\s\r\n]*[_\-]+[\s\r\n]+)/
+ let matches = message.matches(of: messageBoardRegex)
+
+ if matches.count == 1 {
+ let range = matches[0].range
+ self.messageBoard.insert(String(message[message.startIndex..<range.lowerBound]), at: 0)
+ } else {
+ self.messageBoard.insert(message, at: 0)
+ }
+ }
func hotlineReceivedServerMessage(message: String) {
// print("Hotline: received server message:\n\(message)")