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
13 changed files with 33 additions and 18 deletions
@@ -81,6 +81,11 @@ struct TimelineReplyView: View {
plainBody: question, plainBody: question,
formattedBody: nil, formattedBody: nil,
icon: .init(kind: .icon(\.polls), cornerRadii: iconCornerRadii)) 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: default:
LoadingReplyView() LoadingReplyView()
@@ -295,7 +300,11 @@ struct TimelineReplyView_Previews: PreviewProvider, TestablePreview {
eventContent: .message(.notice(.init(body: "", formattedBody: attributedStringWithAtRoomMention))))), eventContent: .message(.notice(.init(body: "", formattedBody: attributedStringWithAtRoomMention))))),
TimelineReplyView(placement: .timeline, TimelineReplyView(placement: .timeline,
timelineItemReplyDetails: .loaded(sender: .init(id: "", displayName: "Bob"), 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] previewItems[index]
} }
} }
.padding()
.environmentObject(viewModel.context) .environmentObject(viewModel.context)
.snapshot(delay: 0.2) // Allow member names to load. .snapshot(delay: 0.2) // Allow member names to load.
.previewLayout(.sizeThatFits)
} }
} }
@@ -22,7 +22,7 @@ struct RedactedRoomTimelineView: View {
var body: some View { var body: some View {
TimelineStyler(timelineItem: timelineItem) { TimelineStyler(timelineItem: timelineItem) {
Label(timelineItem.body, systemImage: "trash") Label(timelineItem.body, icon: \.delete, iconSize: .small, relativeTo: .compound.bodyLG)
.labelStyle(RoomTimelineViewLabelStyle()) .labelStyle(RoomTimelineViewLabelStyle())
.imageScale(.small) // Smaller icon so that the bubble remains rounded on the outside. .imageScale(.small) // Smaller icon so that the bubble remains rounded on the outside.
} }
@@ -26,4 +26,5 @@ enum TimelineItemReplyDetails: Hashable {
enum TimelineEventContent: Hashable { enum TimelineEventContent: Hashable {
case message(EventBasedMessageTimelineItemContentType) case message(EventBasedMessageTimelineItemContentType)
case poll(question: String) case poll(question: String)
case redacted
} }
@@ -645,6 +645,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
replyContent = .poll(question: question) replyContent = .poll(question: question)
case .sticker(let body, _, _): case .sticker(let body, _, _):
replyContent = .message(.text(.init(body: body))) replyContent = .message(.text(.init(body: body)))
case .redactedMessage:
replyContent = .redacted
default: default:
replyContent = .message(.text(.init(body: L10n.commonUnsupportedEvent))) replyContent = .message(.text(.init(body: L10n.commonUnsupportedEvent)))
} }
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:dbe4f20b1c986b7ece28d8927b7ab8cb36561c035b8f73028546fb39944d7794 oid sha256:f84e49036cc65666becdc16e2ea06122467cbff6cb02ba86f0dabca561d582c7
size 87672 size 85898
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:87abbe6892e835ff834711c052b26ef29afda577f825919d21e7ecea8cd30b11 oid sha256:0ecbfa76fa29064d8c3b6f020c03123d13626a6f9ab26fd2a82e7c3b767f7b35
size 96186 size 95532
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:4248e799afc1ca69c1139685b097089e63b105c04bcd54df2d47890afab82d29 oid sha256:90c390789693d762732006b42d9ce2ac3f93fe0bc26c799fa7419930c713196e
size 44405 size 43993
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2360065507e216a4fecd4f00240383c3395ffb733952e6eab790a05fa1f3c2b7 oid sha256:f4efaa78b5203646d7edf9ce621986ad8808c0aa1d3bfd450385638242a3c751
size 53286 size 52887
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2ba7055d8697d93c3f0ebcc63d8cf3842b5fa60fc8b66edb588755ca338d816d oid sha256:89ce8fa7c07e689885a15412c9e9c0654c7bc05946f00cdfca20a6a04ed2ea3f
size 173128 size 188168
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:519ba9280655f12c0d05e9e1a3a61f7155135265ace01dbb0f44b9c63acbbd26 oid sha256:5fe67932ea988edb33e7b25e0456cb0cc81fbd9fa9c96d0a489febab05c8fa17
size 185599 size 207659
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:daf96c0a7cf3fe2b4752155eb50529fba4886571d87c0e3cec7f2067ab3b504d oid sha256:50e73e02c240616cecc831e3bf6275b401e935f8b48c6d6569afd99290475713
size 120507 size 134065
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:3c5fa11dd0a5759d2700e71a2f8391b3f15ab0cc1d0b66c5598b60244a91f23e oid sha256:52d43f12be160d16118a61c355e805c32dec7b6880b346642f39a28d41af4e25
size 130246 size 149521
+1
View File
@@ -0,0 +1 @@
Fix ReplyView when its content has been redacted.