mirror of
https://github.com/metabolist/metatext.git
synced 2025-04-15 16:24:10 +00:00
new feature (copied from glitch-soc :) ) -- option to prepend "re: " to content warnings when replying
This commit is contained in:
parent
667e39554a
commit
cbadbd9c1a
4 changed files with 22 additions and 2 deletions
|
@ -248,6 +248,7 @@
|
|||
"preferences.require-double-tap-to-favorite" = "Require double tap to favorite";
|
||||
"preferences.show-reblog-and-favorite-counts" = "Show boost and favorite counts";
|
||||
"preferences.status-word" = "Status word";
|
||||
"preferences.add-reply-prefix-cw" = "Prepend \"re: \" to content warnings when replying";
|
||||
"filters.active" = "Active";
|
||||
"filters.expired" = "Expired";
|
||||
"filter.add-new" = "Add New Filter";
|
||||
|
|
|
@ -181,6 +181,11 @@ public extension AppPreferences {
|
|||
get { self[.useUniversalLinks] ?? true }
|
||||
set { self[.useUniversalLinks] = newValue }
|
||||
}
|
||||
|
||||
var addReplyPrefixToContentWarning: Bool {
|
||||
get { self[.addReplyPrefixToContentWarning] ?? false }
|
||||
set { self[.addReplyPrefixToContentWarning] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
private extension AppPreferences {
|
||||
|
@ -202,6 +207,7 @@ private extension AppPreferences {
|
|||
case notificationSounds
|
||||
case openLinksInDefaultBrowser
|
||||
case useUniversalLinks
|
||||
case addReplyPrefixToContentWarning
|
||||
}
|
||||
|
||||
subscript<T>(index: Item) -> T? {
|
||||
|
|
|
@ -22,6 +22,8 @@ public final class NewStatusViewModel: ObservableObject {
|
|||
private let compositionEventsSubject = PassthroughSubject<CompositionViewModel.Event, Never>()
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private let REPLY_CONTENT_WARNING_PREFIX = "re: "
|
||||
|
||||
// swiftlint:disable:next function_body_length
|
||||
public init(allIdentitiesService: AllIdentitiesService,
|
||||
identityContext: IdentityContext,
|
||||
|
@ -83,8 +85,17 @@ public final class NewStatusViewModel: ObservableObject {
|
|||
compositionViewModel.text = mentions.joined(separator: " ").appending(" ")
|
||||
}
|
||||
|
||||
compositionViewModel.contentWarning = inReplyTo.spoilerText
|
||||
compositionViewModel.displayContentWarning = !inReplyTo.spoilerText.isEmpty
|
||||
let contentWarning = inReplyTo.spoilerText
|
||||
let hasContentWarning = !contentWarning.isEmpty
|
||||
|
||||
let needsPrefix =
|
||||
hasContentWarning
|
||||
&& identityContext.appPreferences.addReplyPrefixToContentWarning
|
||||
&& !contentWarning.hasPrefix(REPLY_CONTENT_WARNING_PREFIX)
|
||||
let prefix = needsPrefix ? REPLY_CONTENT_WARNING_PREFIX : ""
|
||||
|
||||
compositionViewModel.displayContentWarning = hasContentWarning
|
||||
compositionViewModel.contentWarning = prefix + contentWarning
|
||||
} else if let directMessageTo = directMessageTo {
|
||||
compositionViewModel.text = directMessageTo.accountName.appending(" ")
|
||||
visibility = .direct
|
||||
|
|
|
@ -142,6 +142,8 @@ struct PreferencesView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
Toggle("preferences.add-reply-prefix-cw",
|
||||
isOn: $identityContext.appPreferences.addReplyPrefixToContentWarning)
|
||||
}
|
||||
}
|
||||
.navigationTitle("preferences")
|
||||
|
|
Loading…
Reference in a new issue