From 4419d3107720398f433119a9d133db76dcc7594b Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Thu, 25 May 2023 09:24:20 +1000 Subject: [PATCH] Removed the ability to swipe-to-reply to sending/failed outgoing messages --- .../Context Menu/ContextMenuVC+Action.swift | 18 +++++++++++------- .../Message Cells/VisibleMessageCell.swift | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Session/Conversations/Context Menu/ContextMenuVC+Action.swift b/Session/Conversations/Context Menu/ContextMenuVC+Action.swift index 82d50360b..1c9265e90 100644 --- a/Session/Conversations/Context Menu/ContextMenuVC+Action.swift +++ b/Session/Conversations/Context Menu/ContextMenuVC+Action.swift @@ -131,6 +131,16 @@ extension ContextMenuVC { ) { delegate?.contextMenuDismissed() } } } + + static func viewModelCanReply(_ cellViewModel: MessageViewModel) -> Bool { + return ( + cellViewModel.variant == .standardIncoming || ( + cellViewModel.variant == .standardOutgoing && + cellViewModel.state != .failed && + cellViewModel.state != .sending + ) + ) + } static func actions( for cellViewModel: MessageViewModel, @@ -161,12 +171,6 @@ extension ContextMenuVC { ) ) ) - let canReply: Bool = ( - cellViewModel.variant != .standardOutgoing || ( - cellViewModel.state != .failed && - cellViewModel.state != .sending - ) - ) let canCopy: Bool = ( cellViewModel.cellType == .textOnlyMessage || ( ( @@ -219,7 +223,7 @@ extension ContextMenuVC { let generatedActions: [Action] = [ (canRetry ? Action.retry(cellViewModel, delegate) : nil), - (canReply ? Action.reply(cellViewModel, delegate) : nil), + (viewModelCanReply(cellViewModel) ? Action.reply(cellViewModel, delegate) : nil), (canCopy ? Action.copy(cellViewModel, delegate) : nil), (canSave ? Action.save(cellViewModel, delegate) : nil), (canCopySessionId ? Action.copySessionID(cellViewModel, delegate) : nil), diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index 8def1187d..0a6c010eb 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -400,11 +400,11 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate { ) // Swipe to reply - if cellViewModel.variant == .standardIncomingDeleted || cellViewModel.variant == .infoCall { - removeGestureRecognizer(panGestureRecognizer) + if ContextMenuVC.viewModelCanReply(cellViewModel) { + addGestureRecognizer(panGestureRecognizer) } else { - addGestureRecognizer(panGestureRecognizer) + removeGestureRecognizer(panGestureRecognizer) } // Under bubble content