mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 17:51:01 +00:00
Update status on fetching detail
This commit is contained in:
parent
23fe7d3373
commit
adf8d004f7
2 changed files with 8 additions and 3 deletions
|
@ -31,8 +31,8 @@ public final class StatusDataControllerProvider {
|
|||
|
||||
public func dataController(for status: any AnyStatus, client: Client) -> StatusDataController {
|
||||
let key = CacheKey(statusId: status.id, client: client)
|
||||
if let controller = cache[key] {
|
||||
return controller as! StatusDataController
|
||||
if let controller = cache[key] as? StatusDataController {
|
||||
return controller
|
||||
}
|
||||
let controller = StatusDataController(status: status, client: client)
|
||||
cache[key] = controller
|
||||
|
@ -66,7 +66,7 @@ public final class StatusDataController: StatusDataControlling {
|
|||
self.favoritesCount = status.favouritesCount
|
||||
}
|
||||
|
||||
private func updateFrom(status: Status) {
|
||||
public func updateFrom(status: Status) {
|
||||
self.isReblogged = status.reblogged == true
|
||||
self.isBookmarked = status.bookmarked == true
|
||||
self.isFavorited = status.favourited == true
|
||||
|
|
|
@ -150,6 +150,11 @@ public struct StatusDetailView: View {
|
|||
}
|
||||
}
|
||||
.id(status.id)
|
||||
.onAppear {
|
||||
StatusDataControllerProvider.shared.dataController(for: status.reblog ?? status,
|
||||
client: client)
|
||||
.updateFrom(status: status)
|
||||
}
|
||||
}
|
||||
|
||||
private var errorView: some View {
|
||||
|
|
Loading…
Reference in a new issue