mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-02 19:22:18 +00:00
StatusDataController: Properly fix update cycle
This commit is contained in:
parent
57197b9e9a
commit
05da36c27a
3 changed files with 6 additions and 6 deletions
|
@ -32,7 +32,6 @@ public final class StatusDataControllerProvider {
|
||||||
public func dataController(for status: any AnyStatus, client: Client) -> StatusDataController {
|
public func dataController(for status: any AnyStatus, client: Client) -> StatusDataController {
|
||||||
let key = CacheKey(statusId: status.id, client: client)
|
let key = CacheKey(statusId: status.id, client: client)
|
||||||
if let controller = cache[key] as? StatusDataController {
|
if let controller = cache[key] as? StatusDataController {
|
||||||
controller.updateFrom(status: status, publishUpdate: false)
|
|
||||||
return controller
|
return controller
|
||||||
}
|
}
|
||||||
let controller = StatusDataController(status: status, client: client)
|
let controller = StatusDataController(status: status, client: client)
|
||||||
|
|
|
@ -150,11 +150,6 @@ public struct StatusDetailView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.id(status.id)
|
.id(status.id)
|
||||||
.onAppear {
|
|
||||||
StatusDataControllerProvider.shared.dataController(for: status.reblog ?? status,
|
|
||||||
client: client)
|
|
||||||
.updateFrom(status: status, publishUpdate: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var errorView: some View {
|
private var errorView: some View {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import Foundation
|
||||||
import Models
|
import Models
|
||||||
import Network
|
import Network
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import Env
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class StatusDetailViewModel: ObservableObject {
|
class StatusDetailViewModel: ObservableObject {
|
||||||
|
@ -78,6 +79,11 @@ class StatusDetailViewModel: ObservableObject {
|
||||||
var statuses = data.context.ancestors
|
var statuses = data.context.ancestors
|
||||||
statuses.append(data.status)
|
statuses.append(data.status)
|
||||||
statuses.append(contentsOf: data.context.descendants)
|
statuses.append(contentsOf: data.context.descendants)
|
||||||
|
|
||||||
|
StatusDataControllerProvider.shared.dataController(for: data.status,
|
||||||
|
client: client)
|
||||||
|
.updateFrom(status: data.status, publishUpdate: true)
|
||||||
|
|
||||||
if animate {
|
if animate {
|
||||||
withAnimation {
|
withAnimation {
|
||||||
isLoadingContext = false
|
isLoadingContext = false
|
||||||
|
|
Loading…
Reference in a new issue