From 7ca48e9c7bd8e905d5843321b77c29e28ec97125 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 18 Aug 2022 14:37:33 +1000 Subject: [PATCH] tweak: fix clear all action for open group moderators --- Session.xcodeproj/project.pbxproj | 2 +- Session/Conversations/ConversationVC+Interaction.swift | 10 ++++++---- .../Views & Modals/ReactionListSheet.swift | 10 ++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 8b7d37a4b..f8ab9478f 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -3528,10 +3528,10 @@ FD17D79527F3E04600122BE0 /* _001_InitialSetupMigration.swift */, FDF0B7412804EA4F004C14C5 /* _002_SetupStandardJobs.swift */, FD17D79827F40AB800122BE0 /* _003_YDBToGRDBMigration.swift */, - FD09B7E4288670BB00ED0B66 /* _007_EmojiReacts.swift */, FDF40CDD2897A1BC006A0CC4 /* _004_RemoveLegacyYDB.swift */, FD37EA0C28AB2A45003AE748 /* _005_FixDeletedMessageReadState.swift */, FD37EA0E28AB3330003AE748 /* _006_FixHiddenModAdminSupport.swift */, + FD09B7E4288670BB00ED0B66 /* _007_EmojiReacts.swift */, ); path = Migrations; sourceTree = ""; diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index 27c1d4e8e..5f3e9b1ba 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -978,7 +978,12 @@ extension ConversationVC: reactionListSheet.handleInteractionUpdates( allMessages, selectedReaction: selectedReaction, - initialLoad: true + initialLoad: true, + shouldShowClearAllButton: OpenGroupManager.isUserModeratorOrAdmin( + self.viewModel.threadData.currentUserPublicKey, + for: self.viewModel.threadData.openGroupRoomToken, + on: self.viewModel.threadData.openGroupServer + ) ) reactionListSheet.modalPresentationStyle = .overFullScreen present(reactionListSheet, animated: true, completion: nil) @@ -1176,9 +1181,6 @@ extension ConversationVC: in: thread ) } - }, - completion: { [weak self] _, _ in - self?.handleMessageSent() } ) } diff --git a/Session/Conversations/Views & Modals/ReactionListSheet.swift b/Session/Conversations/Views & Modals/ReactionListSheet.swift index 95ca5b7d6..03e1f039a 100644 --- a/Session/Conversations/Views & Modals/ReactionListSheet.swift +++ b/Session/Conversations/Views & Modals/ReactionListSheet.swift @@ -186,7 +186,8 @@ final class ReactionListSheet: BaseVC { _ allMessages: [MessageViewModel], selectedReaction: EmojiWithSkinTones? = nil, updatedReactionIndex: Int? = nil, - initialLoad: Bool = false + initialLoad: Bool = false, + shouldShowClearAllButton: Bool = false ) { guard let cellViewModel: MessageViewModel = allMessages.first(where: { $0.id == self.interactionId }) else { return @@ -254,10 +255,8 @@ final class ReactionListSheet: BaseVC { } // Update the general UI - self.detailInfoLabel.text = updatedSummaries[safe: updatedSelectedReactionIndex]?.description - self.clearAllButton.isHidden = !cellViewModel.isSenderOpenGroupModerator - + // Update general properties self.messageViewModel = cellViewModel self.lastSelectedReactionIndex = updatedSelectedReactionIndex @@ -271,6 +270,9 @@ final class ReactionListSheet: BaseVC { .map { updatedReactionInfo.value(forKey: $0) } .defaulting(to: []) + // Update clear all button visibility + self.clearAllButton.isHidden = !shouldShowClearAllButton + UIView.performWithoutAnimation { self.reactionContainer.reloadData() self.userListView.reloadData()