Various timeline fixes for smoother scrolling

This commit is contained in:
Thomas Ricouard 2023-02-16 08:52:11 +01:00
parent 64bee206b9
commit 41fdb3adde
2 changed files with 13 additions and 7 deletions

View File

@ -73,9 +73,6 @@ public struct StatusRowView: View {
await viewModel.loadEmbeddedStatus()
}
}
if preferences.autoExpandSpoilers == true && viewModel.displaySpoiler {
viewModel.displaySpoiler = false
}
}
}
.contextMenu {

View File

@ -39,7 +39,7 @@ public class StatusRowViewModel: ObservableObject {
private let theme = Theme.shared
var seen = false
private var seen = false
var filter: Filtered? {
status.reblog?.filtered?.first ?? status.filtered?.first
@ -87,7 +87,11 @@ public class StatusRowViewModel: ObservableObject {
favoritesCount = status.reblog?.favouritesCount ?? status.favouritesCount
reblogsCount = status.reblog?.reblogsCount ?? status.reblogsCount
repliesCount = status.reblog?.repliesCount ?? status.repliesCount
displaySpoiler = !(status.reblog?.spoilerText.asRawText ?? status.spoilerText.asRawText).isEmpty
if UserPreferences.shared.autoExpandSpoilers {
displaySpoiler = false
} else {
displaySpoiler = !(status.reblog?.spoilerText.asRawText ?? status.spoilerText.asRawText).isEmpty
}
isFiltered = filter != nil
}
@ -95,8 +99,13 @@ public class StatusRowViewModel: ObservableObject {
func markSeen() {
// called in on appear so we can cache that the status has been seen.
if UserPreferences.shared.suppressDupeReblogs && !seen {
ReblogCache.shared.cache(status, seen: true)
seen = true
DispatchQueue.global().async { [weak self] in
guard let self else { return }
ReblogCache.shared.cache(self.status, seen: true)
Task { @MainActor in
self.seen = true
}
}
}
}