Skip to content

Commit 1ab09e2

Browse files
committed
Merge branch 'develop' into swift-6
2 parents 4b305c5 + 15a0f70 commit 1ab09e2

File tree

5 files changed

+75
-7
lines changed

5 files changed

+75
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

66
### ✅ Added
77
- Add extra data to user display info [#819](https://github.com/GetStream/stream-chat-swiftui/pull/819)
8+
- Make message spacing in message list configurable [#830](https://github.com/GetStream/stream-chat-swiftui/pull/830)
89
### 🐞 Fixed
910
- Fix swipe to reply enabled when quoting a message is disabled [#824](https://github.com/GetStream/stream-chat-swiftui/pull/824)
1011
- Fix mark unread action not removed when read events are disabled [#823](https://github.com/GetStream/stream-chat-swiftui/pull/823)
1112
- Fix user mentions not working when commands are disabled [#826](https://github.com/GetStream/stream-chat-swiftui/pull/826)
13+
- Fix edit message action shown when user does not have permissions [#835](https://github.com/GetStream/stream-chat-swiftui/pull/835)
1214

1315
# [4.78.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.78.0)
1416
_April 24, 2025_

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageContainerView.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
3333
@GestureState private var offset: CGSize = .zero
3434

3535
private let replyThreshold: CGFloat = 60
36-
private let paddingValue: CGFloat = 8
36+
private var paddingValue: CGFloat {
37+
utils.messageListConfig.messagePaddings.singleBottom
38+
}
39+
40+
private var groupMessageInterItemSpacing: CGFloat {
41+
utils.messageListConfig.messagePaddings.groupBottom
42+
}
3743

3844
var isSwipeToReplyPossible: Bool {
3945
message.isInteractionEnabled && channel.canQuoteMessage
@@ -275,7 +281,7 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
275281
topReactionsShown && !isMessagePinned ? messageListConfig.messageDisplayOptions.reactionsTopPadding(message) : 0
276282
)
277283
.padding(.horizontal, messageListConfig.messagePaddings.horizontal)
278-
.padding(.bottom, showsAllInfo || isMessagePinned ? paddingValue : 2)
284+
.padding(.bottom, showsAllInfo || isMessagePinned ? paddingValue : groupMessageInterItemSpacing)
279285
.padding(.top, isLast ? paddingValue : 0)
280286
.background(isMessagePinned ? Color(colors.pinnedBackground) : nil)
281287
.padding(.bottom, isMessagePinned ? paddingValue / 2 : 0)

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,19 @@ public struct MessagePaddings {
110110
/// Horizontal padding for messages.
111111
public let horizontal: CGFloat
112112
public let quotedViewPadding: CGFloat
113+
public let singleBottom: CGFloat
114+
public let groupBottom: CGFloat
113115

114116
public init(
115117
horizontal: CGFloat = 8,
116-
quotedViewPadding: CGFloat = 8
118+
quotedViewPadding: CGFloat = 8,
119+
singleBottom: CGFloat = 8,
120+
groupBottom: CGFloat = 2
117121
) {
118122
self.horizontal = horizontal
119123
self.quotedViewPadding = quotedViewPadding
124+
self.singleBottom = singleBottom
125+
self.groupBottom = groupBottom
120126
}
121127
}
122128

Sources/StreamChatSwiftUI/ChatChannel/Reactions/MessageActions/DefaultMessageActions.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,18 @@ public extension MessageAction {
145145
}
146146
}
147147

148-
if message.isSentByCurrentUser {
149-
if message.poll == nil && message.giphyAttachments.isEmpty {
148+
if message.poll == nil, message.giphyAttachments.isEmpty {
149+
if channel.canUpdateAnyMessage || channel.canUpdateOwnMessage && message.isSentByCurrentUser {
150150
let editAction = editMessageAction(
151151
for: message,
152152
channel: channel,
153153
onFinish: onFinish
154154
)
155155
messageActions.append(editAction)
156156
}
157-
157+
}
158+
159+
if message.isSentByCurrentUser {
158160
let deleteAction = deleteMessageAction(
159161
for: message,
160162
channel: channel,

StreamChatSwiftUITests/Tests/ChatChannel/MessageActions_Tests.swift

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,64 @@ import XCTest
323323
XCTAssertEqual(messageActions[3].title, "Copy Message")
324324
XCTAssertEqual(messageActions[4].title, "Delete Message")
325325
}
326+
327+
func test_messageActions_currentUser_editingDisabledWhenNoUpdateCapabilities() {
328+
// Given
329+
let channel = ChatChannel.mockDMChannel(ownCapabilities: [])
330+
let message = ChatMessage.mock(
331+
id: .unique,
332+
cid: channel.cid,
333+
text: "Test",
334+
author: .mock(id: chatClient.currentUserId!),
335+
isSentByCurrentUser: true
336+
)
337+
let factory = DefaultViewFactory.shared
338+
339+
// When
340+
let messageActions = MessageAction.defaultActions(
341+
factory: factory,
342+
for: message,
343+
channel: channel,
344+
chatClient: chatClient,
345+
onFinish: { _ in },
346+
onError: { _ in }
347+
)
348+
349+
// Then
350+
XCTAssertFalse(messageActions.contains(where: { $0.title == "Edit Message" }))
351+
}
352+
353+
func test_messageActions_otherUser_editingEnabledWhenUpdateAnyMessageCapability() {
354+
// Given
355+
let channel = ChatChannel.mockDMChannel(ownCapabilities: [.updateAnyMessage])
356+
let message = ChatMessage.mock(
357+
id: .unique,
358+
cid: channel.cid,
359+
text: "Test",
360+
author: .mock(id: .unique),
361+
isSentByCurrentUser: false
362+
)
363+
let factory = DefaultViewFactory.shared
364+
365+
// When
366+
let messageActions = MessageAction.defaultActions(
367+
factory: factory,
368+
for: message,
369+
channel: channel,
370+
chatClient: chatClient,
371+
onFinish: { _ in },
372+
onError: { _ in }
373+
)
374+
375+
// Then
376+
XCTAssertTrue(messageActions.contains(where: { $0.title == "Edit Message" }))
377+
}
326378

327379
// MARK: - Private
328380

329381
private var mockDMChannel: ChatChannel {
330382
ChatChannel.mockDMChannel(
331-
ownCapabilities: [.sendMessage, .uploadFile, .pinMessage, .readEvents]
383+
ownCapabilities: [.updateOwnMessage, .sendMessage, .uploadFile, .pinMessage, .readEvents]
332384
)
333385
}
334386
}

0 commit comments

Comments
 (0)