Restore / Fix embed status view

This commit is contained in:
Thomas Ricouard 2023-01-22 09:51:43 +01:00
parent 987f259130
commit 2df40ff543
1 changed files with 26 additions and 8 deletions

View File

@ -57,14 +57,16 @@ public struct StatusRowView: View {
}
}
.onAppear {
viewModel.client = client
if !viewModel.isCompact, viewModel.embeddedStatus == nil {
Task {
await viewModel.loadEmbeddedStatus()
if reasons.isEmpty {
viewModel.client = client
if !viewModel.isCompact, viewModel.embeddedStatus == nil {
Task {
await viewModel.loadEmbeddedStatus()
}
}
if preferences.serverPreferences?.autoExpandSpoilers == true {
viewModel.displaySpoiler = false
}
}
if preferences.serverPreferences?.autoExpandSpoilers == true {
viewModel.displaySpoiler = false
}
}
.contextMenu {
@ -241,7 +243,9 @@ public struct StatusRowView: View {
if let poll = status.poll {
StatusPollView(poll: poll, status: status)
}
embedStatusView
makeMediasView(status: status)
.accessibilityHidden(!viewModel.isFocused)
makeCardView(status: status)
@ -350,4 +354,18 @@ public struct StatusRowView: View {
StatusCardView(card: card)
}
}
@ViewBuilder
private var embedStatusView: some View {
if !reasons.contains(.placeholder) {
if !viewModel.isCompact, !viewModel.isEmbedLoading,
let embed = viewModel.embeddedStatus {
StatusEmbeddedView(status: embed)
} else if viewModel.isEmbedLoading, !viewModel.isCompact {
StatusEmbeddedView(status: .placeholder())
.redacted(reason: .placeholder)
.shimmering()
}
}
}
}