Add preference for requiring confirmation before reblogging
This commit is contained in:
parent
13a4221fce
commit
8ea15d3bab
|
@ -58,6 +58,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
self.expandAllContentWarnings = try container.decodeIfPresent(Bool.self, forKey: .expandAllContentWarnings) ?? false
|
self.expandAllContentWarnings = try container.decodeIfPresent(Bool.self, forKey: .expandAllContentWarnings) ?? false
|
||||||
self.collapseLongPosts = try container.decodeIfPresent(Bool.self, forKey: .collapseLongPosts) ?? true
|
self.collapseLongPosts = try container.decodeIfPresent(Bool.self, forKey: .collapseLongPosts) ?? true
|
||||||
self.oppositeCollapseKeywords = try container.decodeIfPresent([String].self, forKey: .oppositeCollapseKeywords) ?? []
|
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.showFavoriteAndReblogCounts = try container.decode(Bool.self, forKey: .showFavoriteAndReblogCounts)
|
||||||
self.defaultNotificationsMode = try container.decode(NotificationsMode.self, forKey: .defaultNotificationsType)
|
self.defaultNotificationsMode = try container.decode(NotificationsMode.self, forKey: .defaultNotificationsType)
|
||||||
|
@ -91,6 +92,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
try container.encode(expandAllContentWarnings, forKey: .expandAllContentWarnings)
|
try container.encode(expandAllContentWarnings, forKey: .expandAllContentWarnings)
|
||||||
try container.encode(collapseLongPosts, forKey: .collapseLongPosts)
|
try container.encode(collapseLongPosts, forKey: .collapseLongPosts)
|
||||||
try container.encode(oppositeCollapseKeywords, forKey: .oppositeCollapseKeywords)
|
try container.encode(oppositeCollapseKeywords, forKey: .oppositeCollapseKeywords)
|
||||||
|
try container.encode(confirmBeforeReblog, forKey: .confirmBeforeReblog)
|
||||||
|
|
||||||
try container.encode(showFavoriteAndReblogCounts, forKey: .showFavoriteAndReblogCounts)
|
try container.encode(showFavoriteAndReblogCounts, forKey: .showFavoriteAndReblogCounts)
|
||||||
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
||||||
|
@ -125,6 +127,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
@Published var expandAllContentWarnings = false
|
@Published var expandAllContentWarnings = false
|
||||||
@Published var collapseLongPosts = true
|
@Published var collapseLongPosts = true
|
||||||
@Published var oppositeCollapseKeywords: [String] = []
|
@Published var oppositeCollapseKeywords: [String] = []
|
||||||
|
@Published var confirmBeforeReblog = false
|
||||||
|
|
||||||
// MARK: Digital Wellness
|
// MARK: Digital Wellness
|
||||||
@Published var showFavoriteAndReblogCounts = true
|
@Published var showFavoriteAndReblogCounts = true
|
||||||
|
@ -157,6 +160,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
case expandAllContentWarnings
|
case expandAllContentWarnings
|
||||||
case collapseLongPosts
|
case collapseLongPosts
|
||||||
case oppositeCollapseKeywords
|
case oppositeCollapseKeywords
|
||||||
|
case confirmBeforeReblog
|
||||||
|
|
||||||
case showFavoriteAndReblogCounts
|
case showFavoriteAndReblogCounts
|
||||||
case defaultNotificationsType
|
case defaultNotificationsType
|
||||||
|
|
|
@ -13,14 +13,23 @@ struct BehaviorPrefsView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
|
untitledSection
|
||||||
linksSection
|
linksSection
|
||||||
contentWarningsSection
|
contentWarningsSection
|
||||||
}
|
}
|
||||||
.listStyle(InsetGroupedListStyle())
|
.listStyle(InsetGroupedListStyle())
|
||||||
.navigationBarTitle(Text("Behavior"))
|
.navigationBarTitle(Text("Behavior"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var untitledSection: some View {
|
||||||
|
Section {
|
||||||
|
Toggle(isOn: $preferences.confirmBeforeReblog) {
|
||||||
|
Text("Require Confirmation Before Reblogging")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var linksSection: some View {
|
private var linksSection: some View {
|
||||||
Section(header: Text("Links")) {
|
Section(header: Text("Links")) {
|
||||||
Toggle(isOn: $preferences.openLinksInApps) {
|
Toggle(isOn: $preferences.openLinksInApps) {
|
||||||
Text("Open Links in Apps")
|
Text("Open Links in Apps")
|
||||||
|
@ -34,7 +43,7 @@ struct BehaviorPrefsView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var contentWarningsSection: some View {
|
private var contentWarningsSection: some View {
|
||||||
Section(header: Text("Content Warnings")) {
|
Section(header: Text("Content Warnings")) {
|
||||||
Toggle(isOn: $preferences.collapseLongPosts) {
|
Toggle(isOn: $preferences.collapseLongPosts) {
|
||||||
Text("Collapse Long Posts")
|
Text("Collapse Long Posts")
|
||||||
|
|
|
@ -403,6 +403,23 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
@IBAction func reblogPressed() {
|
@IBAction func reblogPressed() {
|
||||||
guard let status = mastodonController.persistentContainer.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
|
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
|
let oldValue = reblogged
|
||||||
reblogged = !reblogged
|
reblogged = !reblogged
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue