mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +00:00
Add a fast refresh option
This commit is contained in:
parent
f89b3d2761
commit
b249b37612
4 changed files with 136 additions and 3 deletions
|
@ -200,6 +200,9 @@ struct SettingsTabs: View {
|
|||
Toggle(isOn: $preferences.soundEffectEnabled) {
|
||||
Label("settings.other.sound-effect", systemImage: "hifispeaker")
|
||||
}
|
||||
Toggle(isOn: $preferences.fastRefreshEnabled) {
|
||||
Label("settings.other.fast-refresh", systemImage: "arrow.clockwise")
|
||||
}
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
|
|
|
@ -47199,6 +47199,124 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"settings.other.fast-refresh" : {
|
||||
"localizations" : {
|
||||
"be" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"ca" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"de" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"en-GB" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"es" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"eu" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"ko" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"nb" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"nl" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"pl" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"pt-BR" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"tr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"uk" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"value" : "Fast refresh"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings.other.hide-openai" : {
|
||||
"localizations" : {
|
||||
"be" : {
|
||||
|
@ -71483,4 +71601,4 @@
|
|||
}
|
||||
},
|
||||
"version" : "1.0"
|
||||
}
|
||||
}
|
|
@ -53,6 +53,8 @@ import SwiftUI
|
|||
@AppStorage("collapse-long-posts") public var collapseLongPosts = true
|
||||
|
||||
@AppStorage("share-button-behavior") public var shareButtonBehavior: PreferredShareButtonBehavior = .linkAndText
|
||||
|
||||
@AppStorage("fast_refresh") public var fastRefreshEnabled: Bool = false
|
||||
|
||||
init() {}
|
||||
}
|
||||
|
@ -289,6 +291,12 @@ import SwiftUI
|
|||
storage.shareButtonBehavior = shareButtonBehavior
|
||||
}
|
||||
}
|
||||
|
||||
public var fastRefreshEnabled: Bool {
|
||||
didSet {
|
||||
storage.fastRefreshEnabled = fastRefreshEnabled
|
||||
}
|
||||
}
|
||||
|
||||
public enum SwipeActionsIconStyle: String, CaseIterable {
|
||||
case iconWithText, iconOnly
|
||||
|
@ -455,5 +463,6 @@ import SwiftUI
|
|||
shareButtonBehavior = storage.shareButtonBehavior
|
||||
pendingShownAtBottom = storage.pendingShownAtBottom
|
||||
pendingShownLeft = storage.pendingShownLeft
|
||||
fastRefreshEnabled = storage.fastRefreshEnabled
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ extension TimelineViewModel {
|
|||
extension TimelineViewModel: StatusesFetcher {
|
||||
func pullToRefresh() async {
|
||||
timelineTask?.cancel()
|
||||
if !timeline.supportNewestPagination {
|
||||
if !timeline.supportNewestPagination || UserPreferences.shared.fastRefreshEnabled {
|
||||
await reset()
|
||||
}
|
||||
await fetchNewestStatuses()
|
||||
|
@ -168,6 +168,9 @@ extension TimelineViewModel: StatusesFetcher {
|
|||
func refreshTimeline() {
|
||||
timelineTask?.cancel()
|
||||
timelineTask = Task {
|
||||
if UserPreferences.shared.fastRefreshEnabled {
|
||||
await reset()
|
||||
}
|
||||
await fetchNewestStatuses()
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +202,7 @@ extension TimelineViewModel: StatusesFetcher {
|
|||
// Else we fetch top most page from the API.
|
||||
if let cachedStatuses = await getCachedStatuses(),
|
||||
!cachedStatuses.isEmpty,
|
||||
timeline == .home
|
||||
timeline == .home && !UserPreferences.shared.fastRefreshEnabled
|
||||
{
|
||||
await datasource.set(cachedStatuses)
|
||||
if let latestSeenId = await cache.getLatestSeenStatus(for: client)?.last,
|
||||
|
|
Loading…
Reference in a new issue