diff --git a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift index 6f2fccee..b261cc12 100644 --- a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift +++ b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift @@ -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) } diff --git a/IceCubesApp/Resources/Localization/Localizable.xcstrings b/IceCubesApp/Resources/Localization/Localizable.xcstrings index 37e970f4..d20824e6 100644 --- a/IceCubesApp/Resources/Localization/Localizable.xcstrings +++ b/IceCubesApp/Resources/Localization/Localizable.xcstrings @@ -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" -} +} \ No newline at end of file diff --git a/Packages/Env/Sources/Env/UserPreferences.swift b/Packages/Env/Sources/Env/UserPreferences.swift index 559efd6c..d08f4c7f 100644 --- a/Packages/Env/Sources/Env/UserPreferences.swift +++ b/Packages/Env/Sources/Env/UserPreferences.swift @@ -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 } } diff --git a/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift b/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift index 8c0959fa..57a7e374 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift @@ -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,