Filter out some actions for failed local echoes (#1184)

* done

* pr suggestion
This commit is contained in:
Mauro
2023-06-27 18:41:18 +02:00
committed by GitHub
parent 13f5ec8a73
commit f54eb78503
9 changed files with 80 additions and 23 deletions
@@ -151,7 +151,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
@ViewBuilder
var interactiveLocalizedSendInfo: some View {
if timelineItem.properties.deliveryStatus == .sendingFailed {
if timelineItem.hasFailedToSend {
backgroundedLocalizedSendInfo
.onTapGesture {
context.sendFailedConfirmationDialogInfo = .init(transactionID: timelineItem.properties.transactionID)
@@ -186,12 +186,12 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
Text(timelineItem.timestamp)
}
if timelineItem.properties.deliveryStatus == .sendingFailed {
if timelineItem.hasFailedToSend {
Image(systemName: "exclamationmark.circle.fill")
}
}
.font(.compound.bodyXS)
.foregroundColor(timelineItem.properties.deliveryStatus == .sendingFailed ? .compound.textCriticalPrimary : .compound.textSecondary)
.foregroundColor(timelineItem.hasFailedToSend ? .compound.textCriticalPrimary : .compound.textSecondary)
.padding(.bottom, shouldFillBubble ? 0 : -4)
}
@@ -32,7 +32,7 @@ extension TextBasedRoomTimelineViewProtocol {
}
// To account for the extra spacing created by the alert icon
if timelineItem.properties.deliveryStatus == .sendingFailed {
if timelineItem.hasFailedToSend {
whiteSpaces += 3
}
@@ -51,6 +51,24 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
return true
}
}
var canAppearInFailedEcho: Bool {
switch self {
case .copy, .redact, .viewSource:
return true
default:
return false
}
}
var canAppearInRedacted: Bool {
switch self {
case .viewSource:
return true
default:
return false
}
}
}
public struct TimelineItemMenu: View {
@@ -70,17 +88,21 @@ public struct TimelineItemMenu: View {
ScrollView {
VStack(alignment: .leading, spacing: 0.0) {
reactionsSection
.padding(.top, 4.0)
.padding(.bottom, 8.0)
Divider()
.background(Color.compound.bgSubtlePrimary)
viewsForActions(actions.actions)
Divider()
.background(Color.compound.bgSubtlePrimary)
if !item.isRedacted, !item.hasFailedToSend {
reactionsSection
.padding(.top, 4.0)
.padding(.bottom, 8.0)
Divider()
.background(Color.compound.bgSubtlePrimary)
}
if !actions.actions.isEmpty {
viewsForActions(actions.actions)
Divider()
.background(Color.compound.bgSubtlePrimary)
}
viewsForActions(actions.debugActions)
}
@@ -238,7 +260,7 @@ public struct TimelineItemMenu: View {
struct TimelineItemMenu_Previews: PreviewProvider {
static let viewModel = RoomScreenViewModel.mock
static var previews: some View {
VStack {
if let item = RoomTimelineItemFixtures.singleMessageChunk.first as? EventBasedTimelineItemProtocol,