From 4041929b3e9a55c53f1c366f71cea65afe16faec Mon Sep 17 00:00:00 2001 From: CMK Date: Mon, 19 Apr 2021 19:13:20 +0800 Subject: [PATCH] feat: fulfill the content warning when compose reply post --- Mastodon/Diffiable/Section/ComposeStatusSection.swift | 1 + Mastodon/Scene/Compose/ComposeViewModel.swift | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Mastodon/Diffiable/Section/ComposeStatusSection.swift b/Mastodon/Diffiable/Section/ComposeStatusSection.swift index d42caa404..91363ef09 100644 --- a/Mastodon/Diffiable/Section/ComposeStatusSection.swift +++ b/Mastodon/Diffiable/Section/ComposeStatusSection.swift @@ -77,6 +77,7 @@ extension ComposeStatusSection { return cell case .input(let replyToStatusObjectID, let attribute): let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: ComposeStatusContentCollectionViewCell.self), for: indexPath) as! ComposeStatusContentCollectionViewCell + cell.statusContentWarningEditorView.textView.text = attribute.contentWarningContent.value cell.textEditorView.text = attribute.composeContent.value ?? "" managedObjectContext.perform { guard let replyToStatusObjectID = replyToStatusObjectID, diff --git a/Mastodon/Scene/Compose/ComposeViewModel.swift b/Mastodon/Scene/Compose/ComposeViewModel.swift index ef744d0b3..587b56f23 100644 --- a/Mastodon/Scene/Compose/ComposeViewModel.swift +++ b/Mastodon/Scene/Compose/ComposeViewModel.swift @@ -112,6 +112,10 @@ final class ComposeViewModel { for acct in mentionAccts { UITextChecker.learnWord(acct) } + if let spoilerText = status.spoilerText, !spoilerText.isEmpty { + self.isContentWarningComposing.value = true + self.composeStatusAttribute.contentWarningContent.value = spoilerText + } let initialComposeContent = mentionAccts.joined(separator: " ") let preInsertedContent: String? = initialComposeContent.isEmpty ? nil : initialComposeContent + " "