mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Cache streamed status
This commit is contained in:
parent
4e77669181
commit
ed80895fcd
1 changed files with 9 additions and 0 deletions
|
@ -72,17 +72,26 @@ class TimelineViewModel: ObservableObject {
|
||||||
{
|
{
|
||||||
pendingStatusesObserver.pendingStatuses.insert(event.status.id, at: 0)
|
pendingStatusesObserver.pendingStatuses.insert(event.status.id, at: 0)
|
||||||
statuses.insert(event.status, at: 0)
|
statuses.insert(event.status, at: 0)
|
||||||
|
Task {
|
||||||
|
await cache(statuses: statuses)
|
||||||
|
}
|
||||||
withAnimation {
|
withAnimation {
|
||||||
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||||
}
|
}
|
||||||
} else if let event = event as? StreamEventDelete {
|
} else if let event = event as? StreamEventDelete {
|
||||||
withAnimation {
|
withAnimation {
|
||||||
statuses.removeAll(where: { $0.id == event.status })
|
statuses.removeAll(where: { $0.id == event.status })
|
||||||
|
Task {
|
||||||
|
await cache(statuses: statuses)
|
||||||
|
}
|
||||||
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||||
}
|
}
|
||||||
} else if let event = event as? StreamEventStatusUpdate {
|
} else if let event = event as? StreamEventStatusUpdate {
|
||||||
if let originalIndex = statuses.firstIndex(where: { $0.id == event.status.id }) {
|
if let originalIndex = statuses.firstIndex(where: { $0.id == event.status.id }) {
|
||||||
statuses[originalIndex] = event.status
|
statuses[originalIndex] = event.status
|
||||||
|
Task {
|
||||||
|
await cache(statuses: statuses)
|
||||||
|
}
|
||||||
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue