Force update status detail

This commit is contained in:
Thomas Ricouard 2023-02-11 20:20:25 +01:00
parent e192135f37
commit ffda5fe6f0
2 changed files with 6 additions and 5 deletions

View File

@ -41,7 +41,7 @@ public struct StatusDetailView: View {
case .loading: case .loading:
loadingDetailView loadingDetailView
case let .display(status, context): case let .display(status, context, date):
if !context.ancestors.isEmpty { if !context.ancestors.isEmpty {
ForEach(context.ancestors) { ancestor in ForEach(context.ancestors) { ancestor in
StatusRowView(viewModel: .init(status: ancestor, isCompact: false)) StatusRowView(viewModel: .init(status: ancestor, isCompact: false))
@ -49,6 +49,7 @@ public struct StatusDetailView: View {
} }
makeCurrentStatusView(status: status) makeCurrentStatusView(status: status)
.id(date)
if !context.descendants.isEmpty { if !context.descendants.isEmpty {
ForEach(context.descendants) { descendant in ForEach(context.descendants) { descendant in

View File

@ -11,7 +11,7 @@ class StatusDetailViewModel: ObservableObject {
var client: Client? var client: Client?
enum State { enum State {
case loading, display(status: Status, context: StatusContext), error(error: Error) case loading, display(status: Status, context: StatusContext, date: Date), error(error: Error)
} }
@Published var state: State = .loading @Published var state: State = .loading
@ -25,7 +25,7 @@ class StatusDetailViewModel: ObservableObject {
} }
init(status: Status) { init(status: Status) {
state = .display(status: status, context: .empty()) state = .display(status: status, context: .empty(), date: Date())
title = "status.post-from-\(status.account.displayNameWithoutEmojis)" title = "status.post-from-\(status.account.displayNameWithoutEmojis)"
statusId = status.id statusId = status.id
remoteStatusURL = nil remoteStatusURL = nil
@ -75,10 +75,10 @@ class StatusDetailViewModel: ObservableObject {
title = "status.post-from-\(data.status.account.displayNameWithoutEmojis)" title = "status.post-from-\(data.status.account.displayNameWithoutEmojis)"
if animate { if animate {
withAnimation { withAnimation {
state = .display(status: data.status, context: data.context) state = .display(status: data.status, context: data.context, date: Date())
} }
} else { } else {
state = .display(status: data.status, context: data.context) state = .display(status: data.status, context: data.context,date: Date())
scrollToId = statusId scrollToId = statusId
} }
} catch { } catch {