Fix status detail

This commit is contained in:
Thomas Ricouard 2023-02-16 18:46:25 +01:00
parent ac32410200
commit 4304977924
2 changed files with 8 additions and 8 deletions

View file

@ -40,8 +40,8 @@ public struct StatusDetailView: View {
case .loading:
loadingDetailView
case let .display(statuses):
makeStatusesListView(statuses: statuses)
case let .display(statuses, date):
makeStatusesListView(statuses: statuses, date: date)
if !isLoaded {
loadingContextView
@ -93,7 +93,7 @@ public struct StatusDetailView: View {
.navigationBarTitleDisplayMode(.inline)
}
private func makeStatusesListView(statuses: [Status]) -> some View {
private func makeStatusesListView(statuses: [Status], date: Date) -> some View {
ForEach(statuses) { status in
var isReplyToPrevious: Bool = false
if let index = statuses.firstIndex(where: { $0.id == status.id }),
@ -113,7 +113,7 @@ public struct StatusDetailView: View {
}
if self.viewModel.statusId == status.id {
makeCurrentStatusView(status: status)
.id(Date())
.id(date.description)
} else {
StatusRowView(viewModel: viewModel)
}

View file

@ -11,7 +11,7 @@ class StatusDetailViewModel: ObservableObject {
var client: Client?
enum State {
case loading, display(statuses: [Status]), error(error: Error)
case loading, display(statuses: [Status], date: Date), error(error: Error)
}
@Published var state: State = .loading
@ -26,7 +26,7 @@ class StatusDetailViewModel: ObservableObject {
}
init(status: Status) {
state = .display(statuses: [status])
state = .display(statuses: [status], date: Date())
title = "status.post-from-\(status.account.displayNameWithoutEmojis)"
statusId = status.id
remoteStatusURL = nil
@ -81,11 +81,11 @@ class StatusDetailViewModel: ObservableObject {
if animate {
withAnimation {
isLoadingContext = false
state = .display(statuses: statuses)
state = .display(statuses: statuses, date: Date())
}
} else {
isLoadingContext = false
state = .display(statuses: statuses)
state = .display(statuses: statuses, date: Date())
scrollToId = statusId
}
} catch {