diff --git a/CHANGELOG.md b/CHANGELOG.md index c75ea1bfc..19b6df623 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix having message edit action on Giphy messages [#806](https://github.com/GetStream/stream-chat-swiftui/pull/806) - Fix being able to long press an unsent Giphy message [#806](https://github.com/GetStream/stream-chat-swiftui/pull/806) - Fix being able to swipe to reply an unsent Giphy message [#806](https://github.com/GetStream/stream-chat-swiftui/pull/806) +- Fix translated message showing original text in message actions overlay [#810](https://github.com/GetStream/stream-chat-swiftui/pull/810) + ### 🔄 Changed - Deprecated `ComposerConfig.attachmentPayloadConverter` in favour of `MessageComposerViewModel.convertAddedAssetsToPayloads()` [#806](https://github.com/GetStream/stream-chat-swiftui/pull/806) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayView.swift b/Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayView.swift index 371d1a35e..7d20b5e1a 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayView.swift @@ -111,24 +111,13 @@ public struct ReactionsOverlayView: View { Group { if messageDisplayInfo.frame.height > messageContainerHeight { ScrollView { - MessageView( - factory: factory, - message: messageDisplayInfo.message, - contentWidth: messageDisplayInfo.contentWidth, - isFirst: messageDisplayInfo.isFirst, - scrolledId: .constant(nil) - ) + messageView } } else { - MessageView( - factory: factory, - message: messageDisplayInfo.message, - contentWidth: messageDisplayInfo.contentWidth, - isFirst: messageDisplayInfo.isFirst, - scrolledId: .constant(nil) - ) + messageView } } + .environment(\.channelTranslationLanguage, channel.membership?.language) .scaleEffect(popIn || willPopOut ? 1 : 0.95) .animation(willPopOut ? .easeInOut : popInAnimation, value: popIn) .offset( @@ -228,6 +217,16 @@ public struct ReactionsOverlayView: View { } } + private var messageView: some View { + MessageView( + factory: factory, + message: messageDisplayInfo.message, + contentWidth: messageDisplayInfo.contentWidth, + isFirst: messageDisplayInfo.isFirst, + scrolledId: .constant(nil) + ) + } + private func dismissReactionsOverlay(completion: @escaping () -> Void) { withAnimation { willPopOut = true diff --git a/StreamChatSwiftUITests/Tests/ChatChannel/ReactionsOverlayView_Tests.swift b/StreamChatSwiftUITests/Tests/ChatChannel/ReactionsOverlayView_Tests.swift index 56a61e4c6..03c4f6dbd 100644 --- a/StreamChatSwiftUITests/Tests/ChatChannel/ReactionsOverlayView_Tests.swift +++ b/StreamChatSwiftUITests/Tests/ChatChannel/ReactionsOverlayView_Tests.swift @@ -225,6 +225,36 @@ class ReactionsOverlayView_Tests: StreamChatTestCase { // Then XCTAssert(offset == 12.5) } + + func test_reactionsOverlayView_translated() { + // Given + let testMessage = ChatMessage.mock( + id: "test", + cid: .unique, + text: "Hello", + author: .mock(id: "test", name: "martin"), + translations: [.portuguese: "Olá"] + ) + let messageDisplayInfo = MessageDisplayInfo( + message: testMessage, + frame: self.messageDisplayInfo.frame, + contentWidth: self.messageDisplayInfo.contentWidth, + isFirst: true + ) + let view = VerticallyCenteredView { + ReactionsOverlayView( + factory: DefaultViewFactory.shared, + channel: .mock(cid: .unique, membership: .mock(id: "test", language: .portuguese)), + currentSnapshot: self.overlayImage, + messageDisplayInfo: messageDisplayInfo, + onBackgroundTap: {}, + onActionExecuted: { _ in } + ) + } + + // Then + assertSnapshot(matching: view, as: .image(perceptualPrecision: precision)) + } } struct VerticallyCenteredView: View { diff --git a/StreamChatSwiftUITests/Tests/ChatChannel/__Snapshots__/ReactionsOverlayView_Tests/test_reactionsOverlayView_translated.1.png b/StreamChatSwiftUITests/Tests/ChatChannel/__Snapshots__/ReactionsOverlayView_Tests/test_reactionsOverlayView_translated.1.png new file mode 100644 index 000000000..c346eb2fb Binary files /dev/null and b/StreamChatSwiftUITests/Tests/ChatChannel/__Snapshots__/ReactionsOverlayView_Tests/test_reactionsOverlayView_translated.1.png differ