From 0ad5f17b5a2b789b9d0e1c5e03f928aece8ed3f1 Mon Sep 17 00:00:00 2001 From: Sean Goldin Date: Sun, 22 Jan 2023 11:50:45 -0600 Subject: [PATCH] Include spoiler text count when applicable (#281) --- .../Status/Editor/Components/StatusEditorAccessoryView.swift | 2 +- .../Status/Sources/Status/Editor/StatusEditorViewModel.swift | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift index ce57989c..47f5cf39 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift @@ -201,7 +201,7 @@ struct StatusEditorAccessoryView: View { } private var characterCountView: some View { - Text("\((currentInstance.instance?.configuration?.statuses.maxCharacters ?? 500) - viewModel.statusText.string.utf16.count)") + Text("\((currentInstance.instance?.configuration?.statuses.maxCharacters ?? 500) - viewModel.statusText.string.utf16.count - viewModel.spoilerTextCount)") .foregroundColor(.gray) .font(.scaledCallout) } diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift index 5ae797c7..8128da57 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift @@ -21,6 +21,10 @@ public class StatusEditorViewModel: ObservableObject { } } + var spoilerTextCount: Int { + spoilerOn ? spoilerText.utf16.count : 0 + } + @Published var backupStatusText: NSAttributedString? @Published var showPoll: Bool = false