From 99db842411862bca16c2c59c51f0b3ebe7cbe298 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 16 Sep 2020 17:41:27 -0400 Subject: [PATCH] Fix content warning not being copied when replying --- Tusker/Models/Draft.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Tusker/Models/Draft.swift b/Tusker/Models/Draft.swift index c35cd22c..191a40c8 100644 --- a/Tusker/Models/Draft.swift +++ b/Tusker/Models/Draft.swift @@ -120,12 +120,28 @@ extension MastodonController { var acctsToMention = [String]() var visibility = Preferences.shared.defaultPostVisibility + var contentWarning = "" if let inReplyToID = inReplyToID, let inReplyTo = persistentContainer.status(for: inReplyToID) { acctsToMention.append(inReplyTo.account.acct) acctsToMention.append(contentsOf: inReplyTo.mentions.map(\.acct)) visibility = inReplyTo.visibility + + if !inReplyTo.spoilerText.isEmpty { + switch Preferences.shared.contentWarningCopyMode { + case .doNotCopy: + break + case .asIs: + contentWarning = inReplyTo.spoilerText + case .prependRe: + if inReplyTo.spoilerText.lowercased().starts(with: "re:") { + contentWarning = inReplyTo.spoilerText + } else { + contentWarning = "re: \(inReplyTo.spoilerText)" + } + } + } } if let mentioningAcct = mentioningAcct { acctsToMention.append(mentioningAcct) @@ -140,6 +156,8 @@ extension MastodonController { draft.text = acctsToMention.map { "@\($0) " }.joined() draft.initialText = draft.text draft.visibility = visibility + draft.contentWarning = contentWarning + draft.contentWarningEnabled = !contentWarning.isEmpty return draft }