Fixes #4222 - Hide timeline item actions that the user's power level does not allow

This commit is contained in:
Stefan Ceriu
2025-06-18 17:02:49 +03:00
committed by Stefan Ceriu
parent f04f3e74a7
commit ccb0fc7de0
7 changed files with 14 additions and 2 deletions
@@ -342,6 +342,7 @@ struct TimelineItemMenu_Previews: PreviewProvider, TestablePreview {
deliveryStatus: TimelineItemDeliveryStatus? = nil) -> (EventBasedTimelineItemProtocol, TimelineItemMenuActions)! {
guard var item = makeItem(itemType: itemType) else { return nil }
let provider = TimelineItemMenuActionProvider(timelineItem: item,
canCurrentUserSendMessage: true,
canCurrentUserRedactSelf: true,
canCurrentUserRedactOthers: false,
canCurrentUserPin: true,
@@ -10,6 +10,7 @@ import Foundation
@MainActor
struct TimelineItemMenuActionProvider {
let timelineItem: RoomTimelineItemProtocol
let canCurrentUserSendMessage: Bool
let canCurrentUserRedactSelf: Bool
let canCurrentUserRedactOthers: Bool
let canCurrentUserPin: Bool
@@ -47,7 +48,7 @@ struct TimelineItemMenuActionProvider {
actions.append(.endPoll(pollStartID: eventID))
}
if item.canBeRepliedTo {
if item.canBeRepliedTo, canCurrentUserSendMessage {
if let messageItem = item as? EventBasedMessageTimelineItemProtocol {
actions.append(.reply(isThread: messageItem.properties.isThreaded))
} else {
@@ -63,7 +64,7 @@ struct TimelineItemMenuActionProvider {
actions.append(.forward(itemID: item.id))
}
if item.isEditable {
if item.isEditable, canCurrentUserSendMessage {
if item.supportsMediaCaption {
if item.hasMediaCaption {
actions.append(.editCaption)