Add Jump to Latest to clear out cache and reload home timeline
This commit is contained in:
parent
f4a2d4fcc3
commit
5afd2dc73c
|
@ -76,6 +76,14 @@ struct TimelineTab: View {
|
|||
|
||||
@ViewBuilder
|
||||
private var timelineFilterButton: some View {
|
||||
if timeline == .home {
|
||||
Button {
|
||||
self.timeline = .latest
|
||||
} label: {
|
||||
Label(TimelineFilter.latest.localizedTitle(), systemImage: TimelineFilter.latest.iconName() ?? "")
|
||||
}
|
||||
Divider()
|
||||
}
|
||||
ForEach(TimelineFilter.availableTimeline(client: client), id: \.self) { timeline in
|
||||
Button {
|
||||
self.timeline = timeline
|
||||
|
|
|
@ -298,6 +298,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Federada";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Inici";
|
||||
"timeline.local" = "Local";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld publicació recents de %lld participants";
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Föderiert";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Startseite";
|
||||
"timeline.local" = "Lokal";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld aktuelle Beiträge von %lld Teilnehmenden";
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Federated";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Home";
|
||||
"timeline.local" = "Local";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld recent posts from %lld participants";
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Federated";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Home";
|
||||
"timeline.local" = "Local";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld recent posts from %lld participants";
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Federado";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Inicio";
|
||||
"timeline.local" = "Local";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld publicaciones recientes de %lld participantes";
|
||||
|
|
|
@ -295,6 +295,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Fédéré";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Accueil";
|
||||
"timeline.local" = "Local";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld publications récentes de %lld participants";
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Federazione";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Home";
|
||||
"timeline.local" = "Locale";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld post recenti da %lld partecipanti";
|
||||
|
|
|
@ -299,6 +299,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "連合";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "ホーム";
|
||||
"timeline.local" = "ローカル";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld トゥートの投稿 %lld 人が投稿している";
|
||||
|
|
|
@ -301,6 +301,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "연합";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "홈";
|
||||
"timeline.local" = "로컬";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld개의 최근 글 (%lld명의 사용자가 이야기 중)";
|
||||
|
|
|
@ -299,6 +299,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Federert";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Hjem";
|
||||
"timeline.local" = "Lokal";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld nylige innlegg fra %lld deltakere";
|
||||
|
|
|
@ -293,6 +293,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Gefedereerd";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Start";
|
||||
"timeline.local" = "Lokaal";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld recente posts van %lld deelnemers";
|
||||
|
|
|
@ -296,6 +296,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Strumień globalny";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Strona domowa";
|
||||
"timeline.local" = "Strumień lokalny";
|
||||
"timeline.trending" = "Teraz popularne";
|
||||
|
|
|
@ -299,6 +299,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Linha global";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Início";
|
||||
"timeline.local" = "Linha local";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld postagens recentes de %lld participantes";
|
||||
|
|
|
@ -295,6 +295,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "Birleştirilmiş";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "Ana Ekran";
|
||||
"timeline.local" = "Yerel";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "%lld katılımcılar tarafından %lld yeni gönderiler";
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
|
||||
// MARK: Package: Timeline
|
||||
"timeline.federated" = "跨站";
|
||||
"timeline.latest" = "Jump to Latest";
|
||||
"timeline.home" = "主页";
|
||||
"timeline.local" = "本地";
|
||||
"timeline.n-recent-from-n-participants %lld %lld" = "最近 %lld 条嘟文来自 %lld 个参与者";
|
||||
|
|
|
@ -8,6 +8,7 @@ public enum TimelineFilter: Hashable, Equatable {
|
|||
case hashtag(tag: String, accountId: String?)
|
||||
case list(list: Models.List)
|
||||
case remoteLocal(server: String)
|
||||
case latest
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(title)
|
||||
|
@ -22,6 +23,8 @@ public enum TimelineFilter: Hashable, Equatable {
|
|||
|
||||
public var title: String {
|
||||
switch self {
|
||||
case .latest:
|
||||
return "Latest"
|
||||
case .federated:
|
||||
return "Federated"
|
||||
case .local:
|
||||
|
@ -41,6 +44,8 @@ public enum TimelineFilter: Hashable, Equatable {
|
|||
|
||||
public func localizedTitle() -> LocalizedStringKey {
|
||||
switch self {
|
||||
case .latest:
|
||||
return "timeline.latest"
|
||||
case .federated:
|
||||
return "timeline.federated"
|
||||
case .local:
|
||||
|
@ -60,6 +65,8 @@ public enum TimelineFilter: Hashable, Equatable {
|
|||
|
||||
public func iconName() -> String? {
|
||||
switch self {
|
||||
case .latest:
|
||||
return "arrow.counterclockwise"
|
||||
case .federated:
|
||||
return "globe.americas"
|
||||
case .local:
|
||||
|
@ -82,6 +89,7 @@ public enum TimelineFilter: Hashable, Equatable {
|
|||
case .federated: return Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: false)
|
||||
case .local: return Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: true)
|
||||
case .remoteLocal: return Timelines.pub(sinceId: sinceId, maxId: maxId, minId: minId, local: true)
|
||||
case .latest: return Timelines.home(sinceId: nil, maxId: nil, minId: nil)
|
||||
case .home: return Timelines.home(sinceId: sinceId, maxId: maxId, minId: minId)
|
||||
case .trending: return Trends.statuses(offset: offset)
|
||||
case let .list(list): return Timelines.list(listId: list.id, sinceId: sinceId, maxId: maxId, minId: minId)
|
||||
|
|
|
@ -115,6 +115,9 @@ public struct TimelineView: View {
|
|||
}
|
||||
viewModel.timeline = newTimeline
|
||||
}
|
||||
.onChange(of: viewModel.timeline, perform: { newValue in
|
||||
timeline = newValue
|
||||
})
|
||||
.onChange(of: scenePhase, perform: { scenePhase in
|
||||
switch scenePhase {
|
||||
case .active:
|
||||
|
|
|
@ -11,6 +11,10 @@ class TimelineViewModel: ObservableObject {
|
|||
@Published var timeline: TimelineFilter = .federated {
|
||||
didSet {
|
||||
Task {
|
||||
if timeline == .latest, let client {
|
||||
await cache.clearCache(for: client)
|
||||
timeline = .home
|
||||
}
|
||||
if oldValue != timeline {
|
||||
statuses = []
|
||||
pendingStatusesObserver.pendingStatuses = []
|
||||
|
|
Loading…
Reference in New Issue