From 43049779241e1cc230823c097b379fd252dc6084 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Thu, 16 Feb 2023 18:46:25 +0100 Subject: [PATCH] Fix status detail --- .../Status/Sources/Status/Detail/StatusDetailView.swift | 8 ++++---- .../Sources/Status/Detail/StatusDetailViewModel.swift | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Packages/Status/Sources/Status/Detail/StatusDetailView.swift b/Packages/Status/Sources/Status/Detail/StatusDetailView.swift index 6d8c8689..b379641c 100644 --- a/Packages/Status/Sources/Status/Detail/StatusDetailView.swift +++ b/Packages/Status/Sources/Status/Detail/StatusDetailView.swift @@ -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) } diff --git a/Packages/Status/Sources/Status/Detail/StatusDetailViewModel.swift b/Packages/Status/Sources/Status/Detail/StatusDetailViewModel.swift index 9cbb7354..bf187434 100644 --- a/Packages/Status/Sources/Status/Detail/StatusDetailViewModel.swift +++ b/Packages/Status/Sources/Status/Detail/StatusDetailViewModel.swift @@ -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 {