From 11dea25131221c97ccbeb85631e652c5c067f3af Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Fri, 7 Mar 2025 21:19:23 +0000 Subject: [PATCH] ios: fix production render --- apps/ios/Shared/Views/Chat/ChatView.swift | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/ios/Shared/Views/Chat/ChatView.swift b/apps/ios/Shared/Views/Chat/ChatView.swift index 1e4c16b036..f9981891d3 100644 --- a/apps/ios/Shared/Views/Chat/ChatView.swift +++ b/apps/ios/Shared/Views/Chat/ChatView.swift @@ -1647,9 +1647,9 @@ struct ChatView: View { } deleteButton(ci, label: "Delete report") } else if let mc = ci.content.msgContent, !ci.isReport, ci.meta.itemDeleted == nil || revealed { - if chat.chatInfo.featureEnabled(.reactions) && ci.allowAddReaction, - availableReactions.count > 0 { - reactionsGroup + let rs = availableReactions() + if chat.chatInfo.featureEnabled(.reactions) && ci.allowAddReaction && rs.count > 0 { + reactionsGroup(rs) } if ci.meta.itemDeleted == nil && !ci.isLiveDummy && !live && !ci.localNote { replyButton @@ -1762,21 +1762,21 @@ struct ChatView: View { } } - private var reactionsGroup: some View { + private func reactionsGroup(_ rs: Array) -> some View { if #available(iOS 16.4, *) { return ControlGroup { - if availableReactions.count > 4 { - reactions(till: 3) + if rs.count > 4 { + reactions(rs, till: 3) Menu { - reactions(from: 3) + reactions(rs, from: 3) } label: { Image(systemName: "ellipsis") } - } else { reactions() } + } else { reactions(rs) } }.controlGroupStyle(.compactMenu) } else { return Menu { - reactions() + reactions(rs) } label: { Label( NSLocalizedString("React…", comment: "chat item menu"), @@ -1786,8 +1786,8 @@ struct ChatView: View { } } - func reactions(from: Int? = nil, till: Int? = nil) -> some View { - ForEach(availableReactions[(from ?? 0)..<(till ?? availableReactions.count)]) { reaction in + func reactions(_ rs: Array, from: Int? = nil, till: Int? = nil) -> some View { + ForEach(rs[(from ?? 0)..<(till ?? rs.count)]) { reaction in Button(reaction.text) { setReaction(chatItem, add: true, reaction: reaction) } @@ -1795,7 +1795,7 @@ struct ChatView: View { } /// Reactions, which has not been used yet - private var availableReactions: Array { + private func availableReactions() -> Array { MsgReaction.values .filter { reaction in !chatItem.reactions.contains {