Skip to content

Commit b4b1d4c

Browse files
Config for enforcing unique reactions
1 parent 0861a1d commit b4b1d4c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44
# Upcoming
55

66
### ✅ Added
7-
- Configuration for highlighted composer border color
7+
- Config for highlighted composer border color
8+
- Config for enforcing unique reactions
89

910
### 🐞 Fixed
1011
- Improved loading of gallery images

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public struct MessageListConfig {
2626
scrollingAnchor: UnitPoint = .bottom,
2727
showNewMessagesSeparator: Bool = true,
2828
handleTabBarVisibility: Bool = true,
29-
messageListAlignment: MessageListAlignment = .standard
29+
messageListAlignment: MessageListAlignment = .standard,
30+
uniqueReactionsEnabled: Bool = false
3031
) {
3132
self.messageListType = messageListType
3233
self.typingIndicatorPlacement = typingIndicatorPlacement
@@ -46,6 +47,7 @@ public struct MessageListConfig {
4647
self.showNewMessagesSeparator = showNewMessagesSeparator
4748
self.handleTabBarVisibility = handleTabBarVisibility
4849
self.messageListAlignment = messageListAlignment
50+
self.uniqueReactionsEnabled = uniqueReactionsEnabled
4951
}
5052

5153
public let messageListType: MessageListType
@@ -66,6 +68,7 @@ public struct MessageListConfig {
6668
public let showNewMessagesSeparator: Bool
6769
public let handleTabBarVisibility: Bool
6870
public let messageListAlignment: MessageListAlignment
71+
public let uniqueReactionsEnabled: Bool
6972
}
7073

7174
/// Contains information about the message paddings.

Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayViewModel.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ open class ReactionsOverlayViewModel: ObservableObject, ChatMessageControllerDel
3333
messageController?.deleteReaction(reaction)
3434
} else {
3535
// reaction should be added
36-
messageController?.addReaction(reaction)
36+
messageController?.addReaction(
37+
reaction,
38+
enforceUnique: utils.messageListConfig.uniqueReactionsEnabled
39+
)
3740
}
3841
}
3942

0 commit comments

Comments
 (0)