More fix for #1943

This commit is contained in:
Thomas Ricouard 2024-02-05 14:24:29 +01:00
parent cfd6eed159
commit 75bb4f43dd

View file

@ -61,10 +61,9 @@ public struct StatusRowMediaPreviewView: View {
} else { } else {
ScrollView(.horizontal, showsIndicators: showsScrollIndicators) { ScrollView(.horizontal, showsIndicators: showsScrollIndicators) {
HStack { HStack {
makeAttachmentView(for: 0) ForEach(attachments) { attachment in
makeAttachmentView(for: 1) makeAttachmentView(attachment)
makeAttachmentView(for: 2) }
makeAttachmentView(for: 3)
} }
.padding(.bottom, scrollBottomPadding) .padding(.bottom, scrollBottomPadding)
} }
@ -74,17 +73,18 @@ public struct StatusRowMediaPreviewView: View {
} }
@ViewBuilder @ViewBuilder
private func makeAttachmentView(for index: Int) -> some View { private func makeAttachmentView(_ attachement: MediaAttachment) -> some View {
if if let data = DisplayData(from: attachement) {
attachments.count > index,
let data = DisplayData(from: attachments[index])
{
MediaPreview( MediaPreview(
sensitive: sensitive, sensitive: sensitive,
imageMaxHeight: imageMaxHeight, imageMaxHeight: imageMaxHeight,
displayData: data displayData: data
) )
.onTapGesture { tabAction(for: index) } .onTapGesture {
if let index = attachments.firstIndex(where: { $0.id == attachement.id }) {
tabAction(for: index)
}
}
} }
} }