forked from shadowfacts/Tusker
Add preference to disable timeline state restoration
This commit is contained in:
parent
fc8fcb76fd
commit
3ea7e1057b
|
@ -63,6 +63,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
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.confirmBeforeReblog = try container.decodeIfPresent(Bool.self, forKey: .confirmBeforeReblog) ?? false
|
||||||
|
self.timelineStateRestoration = try container.decodeIfPresent(Bool.self, forKey: .timelineStateRestoration) ?? true
|
||||||
|
|
||||||
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)
|
||||||
|
@ -105,6 +106,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
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(confirmBeforeReblog, forKey: .confirmBeforeReblog)
|
||||||
|
try container.encode(timelineStateRestoration, forKey: .timelineStateRestoration)
|
||||||
|
|
||||||
try container.encode(showFavoriteAndReblogCounts, forKey: .showFavoriteAndReblogCounts)
|
try container.encode(showFavoriteAndReblogCounts, forKey: .showFavoriteAndReblogCounts)
|
||||||
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
||||||
|
@ -156,6 +158,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
@Published var collapseLongPosts = true
|
@Published var collapseLongPosts = true
|
||||||
@Published var oppositeCollapseKeywords: [String] = []
|
@Published var oppositeCollapseKeywords: [String] = []
|
||||||
@Published var confirmBeforeReblog = false
|
@Published var confirmBeforeReblog = false
|
||||||
|
@Published var timelineStateRestoration = true
|
||||||
|
|
||||||
// MARK: Digital Wellness
|
// MARK: Digital Wellness
|
||||||
@Published var showFavoriteAndReblogCounts = true
|
@Published var showFavoriteAndReblogCounts = true
|
||||||
|
@ -199,6 +202,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
case collapseLongPosts
|
case collapseLongPosts
|
||||||
case oppositeCollapseKeywords
|
case oppositeCollapseKeywords
|
||||||
case confirmBeforeReblog
|
case confirmBeforeReblog
|
||||||
|
case timelineStateRestoration
|
||||||
|
|
||||||
case showFavoriteAndReblogCounts
|
case showFavoriteAndReblogCounts
|
||||||
case defaultNotificationsType
|
case defaultNotificationsType
|
||||||
|
|
|
@ -14,6 +14,7 @@ struct BehaviorPrefsView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
untitledSection
|
untitledSection
|
||||||
|
timelineSection
|
||||||
linksSection
|
linksSection
|
||||||
contentWarningsSection
|
contentWarningsSection
|
||||||
}
|
}
|
||||||
|
@ -29,6 +30,16 @@ struct BehaviorPrefsView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var timelineSection: some View {
|
||||||
|
Section {
|
||||||
|
Toggle(isOn: $preferences.timelineStateRestoration) {
|
||||||
|
Text("Maintain Position Across App Launches")
|
||||||
|
}
|
||||||
|
} header: {
|
||||||
|
Text("Timeline")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private 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) {
|
||||||
|
|
|
@ -284,7 +284,8 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||||
}
|
}
|
||||||
|
|
||||||
private func doRestore() -> Bool {
|
private func doRestore() -> Bool {
|
||||||
guard let activity = activityToRestore else {
|
guard let activity = activityToRestore,
|
||||||
|
Preferences.shared.timelineStateRestoration else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
guard let statusIDs = activity.userInfo?["statusIDs"] as? [String] else {
|
guard let statusIDs = activity.userInfo?["statusIDs"] as? [String] else {
|
||||||
|
|
Loading…
Reference in New Issue