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
@@ -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,