Fix timeline cache caching something else than home Fix #710

This commit is contained in:
Thomas Ricouard 2023-02-08 06:52:15 +01:00
parent b30b96c48d
commit 49791d2c86
2 changed files with 4 additions and 2 deletions

View file

@ -20,6 +20,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject {
textView?.pasteDelegate = self
}
}
var selectedRange: NSRange {
get {
guard let textView else {

View file

@ -149,7 +149,7 @@ extension TimelineViewModel: StatusesFetcher {
func fetchStatuses() async {
guard let client else { return }
do {
if statuses.isEmpty {
if statuses.isEmpty || timeline == .trending {
try await fetchFirstPage(client: client)
} else if let latest = statuses.first {
try await fetchNewPagesFrom(latestStatus: latest, client: client)
@ -193,12 +193,13 @@ extension TimelineViewModel: StatusesFetcher {
statuses = try await client.get(endpoint: timeline.endpoint(sinceId: nil,
maxId: nil,
minId: nil,
offset: statuses.count))
offset: 0))
updateMentionsToBeHighlighted(&statuses)
ReblogCache.shared.removeDuplicateReblogs(&statuses)
await cacheHome()
withAnimation {
statusesState = .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage)
}