From 079d6f8c9f14c70605764a66441c48f0cc44bc7f Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Fri, 10 Mar 2023 14:04:29 +1100 Subject: [PATCH] disable the swipe actions when in the "leaving" state --- Session/Home/HomeVC.swift | 2 ++ SessionMessagingKit/Database/Models/Interaction.swift | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/Session/Home/HomeVC.swift b/Session/Home/HomeVC.swift index d95c76515..736a16d86 100644 --- a/Session/Home/HomeVC.swift +++ b/Session/Home/HomeVC.swift @@ -627,6 +627,7 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedRemi return nil case .threads: let threadViewModel: SessionThreadViewModel = section.elements[indexPath.row] + if threadViewModel.interactionVariant?.isGroupLeavingStatus == true { return nil } let hasUnread: Bool = (threadViewModel.threadUnreadCount ?? 0) > 0 let mark: UIContextualAction = UIContextualAction( title: ((hasUnread) ? "mark_read_button_text".localized() : "mark_unread_button_text".localized()), @@ -686,6 +687,7 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedRemi case .threads: let threadViewModel: SessionThreadViewModel = section.elements[indexPath.row] + if threadViewModel.interactionVariant?.isGroupLeavingStatus == true { return nil } let pin: UIContextualAction = UIContextualAction( title: (threadViewModel.threadIsPinned ? "UNPIN_BUTTON_TEXT".localized() : "PIN_BUTTON_TEXT".localized()), diff --git a/SessionMessagingKit/Database/Models/Interaction.swift b/SessionMessagingKit/Database/Models/Interaction.swift index 6ec1f1542..4bd0da58c 100644 --- a/SessionMessagingKit/Database/Models/Interaction.swift +++ b/SessionMessagingKit/Database/Models/Interaction.swift @@ -110,6 +110,15 @@ public struct Interaction: Codable, Identifiable, Equatable, FetchableRecord, Mu } } + public var isGroupLeavingStatus: Bool { + switch self { + case .infoClosedGroupCurrentUserLeft, .infoClosedGroupCurrentUserLeaving, .infoClosedGroupCurrentUserErrorLeaving: + return true + default: + return false + } + } + /// This flag controls whether the `wasRead` flag is automatically set to true based on the message variant (as a result it they will /// or won't affect the unread count) fileprivate var canBeUnread: Bool {