Fix ReplyView when its content has been redacted. (#2606)

This commit is contained in:
Doug 2024-03-27 10:16:26 +00:00 committed by GitHub
parent be9cf8713e
commit bb725db6bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 33 additions and 18 deletions

View File

@ -81,6 +81,11 @@ struct TimelineReplyView: View {
plainBody: question,
formattedBody: nil,
icon: .init(kind: .icon(\.polls), cornerRadii: iconCornerRadii))
case .redacted:
ReplyView(sender: sender,
plainBody: L10n.commonMessageRemoved,
formattedBody: nil,
icon: .init(kind: .icon(\.delete), cornerRadii: iconCornerRadii))
}
default:
LoadingReplyView()
@ -295,7 +300,11 @@ struct TimelineReplyView_Previews: PreviewProvider, TestablePreview {
eventContent: .message(.notice(.init(body: "", formattedBody: attributedStringWithAtRoomMention))))),
TimelineReplyView(placement: .timeline,
timelineItemReplyDetails: .loaded(sender: .init(id: "", displayName: "Bob"),
eventContent: .poll(question: "Do you like polls?")))
eventContent: .poll(question: "Do you like polls?"))),
TimelineReplyView(placement: .timeline,
timelineItemReplyDetails: .loaded(sender: .init(id: "", displayName: "Bob"),
eventContent: .redacted))
]
}
@ -305,7 +314,9 @@ struct TimelineReplyView_Previews: PreviewProvider, TestablePreview {
previewItems[index]
}
}
.padding()
.environmentObject(viewModel.context)
.snapshot(delay: 0.2) // Allow member names to load.
.previewLayout(.sizeThatFits)
}
}

View File

@ -22,7 +22,7 @@ struct RedactedRoomTimelineView: View {
var body: some View {
TimelineStyler(timelineItem: timelineItem) {
Label(timelineItem.body, systemImage: "trash")
Label(timelineItem.body, icon: \.delete, iconSize: .small, relativeTo: .compound.bodyLG)
.labelStyle(RoomTimelineViewLabelStyle())
.imageScale(.small) // Smaller icon so that the bubble remains rounded on the outside.
}

View File

@ -26,4 +26,5 @@ enum TimelineItemReplyDetails: Hashable {
enum TimelineEventContent: Hashable {
case message(EventBasedMessageTimelineItemContentType)
case poll(question: String)
case redacted
}

View File

@ -645,6 +645,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
replyContent = .poll(question: question)
case .sticker(let body, _, _):
replyContent = .message(.text(.init(body: body)))
case .redactedMessage:
replyContent = .redacted
default:
replyContent = .message(.text(.init(body: L10n.commonUnsupportedEvent)))
}

1
changelog.d/2396.bugfix Normal file
View File

@ -0,0 +1 @@
Fix ReplyView when its content has been redacted.