Compare commits
No commits in common. "c737354ed337710b613e4a8e5124b2d819a6b2a1" and "13a4221fce021667f1d49b188b022f8d2acfe829" have entirely different histories.
c737354ed3
...
13a4221fce
|
@ -58,7 +58,6 @@ class Preferences: Codable, ObservableObject {
|
|||
self.expandAllContentWarnings = try container.decodeIfPresent(Bool.self, forKey: .expandAllContentWarnings) ?? false
|
||||
self.collapseLongPosts = try container.decodeIfPresent(Bool.self, forKey: .collapseLongPosts) ?? true
|
||||
self.oppositeCollapseKeywords = try container.decodeIfPresent([String].self, forKey: .oppositeCollapseKeywords) ?? []
|
||||
self.confirmBeforeReblog = try container.decodeIfPresent(Bool.self, forKey: .confirmBeforeReblog) ?? false
|
||||
|
||||
self.showFavoriteAndReblogCounts = try container.decode(Bool.self, forKey: .showFavoriteAndReblogCounts)
|
||||
self.defaultNotificationsMode = try container.decode(NotificationsMode.self, forKey: .defaultNotificationsType)
|
||||
|
@ -92,7 +91,6 @@ class Preferences: Codable, ObservableObject {
|
|||
try container.encode(expandAllContentWarnings, forKey: .expandAllContentWarnings)
|
||||
try container.encode(collapseLongPosts, forKey: .collapseLongPosts)
|
||||
try container.encode(oppositeCollapseKeywords, forKey: .oppositeCollapseKeywords)
|
||||
try container.encode(confirmBeforeReblog, forKey: .confirmBeforeReblog)
|
||||
|
||||
try container.encode(showFavoriteAndReblogCounts, forKey: .showFavoriteAndReblogCounts)
|
||||
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
||||
|
@ -127,7 +125,6 @@ class Preferences: Codable, ObservableObject {
|
|||
@Published var expandAllContentWarnings = false
|
||||
@Published var collapseLongPosts = true
|
||||
@Published var oppositeCollapseKeywords: [String] = []
|
||||
@Published var confirmBeforeReblog = false
|
||||
|
||||
// MARK: Digital Wellness
|
||||
@Published var showFavoriteAndReblogCounts = true
|
||||
|
@ -160,7 +157,6 @@ class Preferences: Codable, ObservableObject {
|
|||
case expandAllContentWarnings
|
||||
case collapseLongPosts
|
||||
case oppositeCollapseKeywords
|
||||
case confirmBeforeReblog
|
||||
|
||||
case showFavoriteAndReblogCounts
|
||||
case defaultNotificationsType
|
||||
|
|
|
@ -57,6 +57,14 @@ struct ComposeContentWarningTextField: UIViewRepresentable {
|
|||
updateAutocompleteState(textField: textField)
|
||||
}
|
||||
|
||||
func textFieldDidChangeSelection(_ textField: UITextField) {
|
||||
// Update text binding before potentially triggering SwiftUI view update.
|
||||
// See comment in MainComposeTextView.Coordinator.textViewDidChangeSelection
|
||||
text.wrappedValue = textField.text ?? ""
|
||||
|
||||
updateAutocompleteState(textField: textField)
|
||||
}
|
||||
|
||||
func autocomplete(with string: String) {
|
||||
guard let textField = textField,
|
||||
let text = textField.text,
|
||||
|
|
|
@ -258,6 +258,21 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
|
|||
updateAutocompleteState()
|
||||
}
|
||||
|
||||
func textViewDidChangeSelection(_ textView: UITextView) {
|
||||
// Update the value of the text binding.
|
||||
// Sometimes, when the user accepts an autocomplete suggestion from the system keyboard, the system
|
||||
// calls didChangeSelection before textDidChange, resulting in a loop where the updating the Tusker autocomplete
|
||||
// state in didChangeSection (via updateAutocompleteState) triggers a new SwiftUI view update,
|
||||
// but when that SwiftUI update is handled, the model still has the old text (from prior to accepting the autocomplete
|
||||
// suggestion), meaning the UITextView's text gets set back to whatever it was prior to the system autocomplete.
|
||||
// To work around that, we also update the text binding in didChangeSelection, to ensure that, if the autocomplete state
|
||||
// does change and trigger a SwiftUI update, the binding will have the correct text that was produced by the system
|
||||
// autocompletion.
|
||||
text.wrappedValue = textView.text ?? ""
|
||||
|
||||
updateAutocompleteState()
|
||||
}
|
||||
|
||||
func autocomplete(with string: String) {
|
||||
guard let textView = textView,
|
||||
let text = textView.text,
|
||||
|
|
|
@ -13,7 +13,6 @@ struct BehaviorPrefsView: View {
|
|||
|
||||
var body: some View {
|
||||
List {
|
||||
untitledSection
|
||||
linksSection
|
||||
contentWarningsSection
|
||||
}
|
||||
|
@ -21,15 +20,7 @@ struct BehaviorPrefsView: View {
|
|||
.navigationBarTitle(Text("Behavior"))
|
||||
}
|
||||
|
||||
private var untitledSection: some View {
|
||||
Section {
|
||||
Toggle(isOn: $preferences.confirmBeforeReblog) {
|
||||
Text("Require Confirmation Before Reblogging")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var linksSection: some View {
|
||||
var linksSection: some View {
|
||||
Section(header: Text("Links")) {
|
||||
Toggle(isOn: $preferences.openLinksInApps) {
|
||||
Text("Open Links in Apps")
|
||||
|
@ -43,7 +34,7 @@ struct BehaviorPrefsView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private var contentWarningsSection: some View {
|
||||
var contentWarningsSection: some View {
|
||||
Section(header: Text("Content Warnings")) {
|
||||
Toggle(isOn: $preferences.collapseLongPosts) {
|
||||
Text("Collapse Long Posts")
|
||||
|
|
|
@ -403,23 +403,6 @@ class BaseStatusTableViewCell: UITableViewCell {
|
|||
@IBAction func reblogPressed() {
|
||||
guard let status = mastodonController.persistentContainer.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
|
||||
|
||||
// if we are about to reblog and the user has confirmation enabled
|
||||
if !reblogged,
|
||||
Preferences.shared.confirmBeforeReblog {
|
||||
let alert = UIAlertController(title: "Confirm Reblog", message: "Are you sure you want to reblog this post by @\(status.account.acct)?", preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
||||
alert.addAction(UIAlertAction(title: "Reblog", style: .default) { (_) in
|
||||
self.toggleReblogInternal()
|
||||
})
|
||||
delegate?.present(alert, animated: true)
|
||||
} else {
|
||||
toggleReblogInternal()
|
||||
}
|
||||
}
|
||||
|
||||
private func toggleReblogInternal() {
|
||||
guard let status = mastodonController.persistentContainer.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
|
||||
|
||||
let oldValue = reblogged
|
||||
reblogged = !reblogged
|
||||
|
||||
|
|
Loading…
Reference in New Issue