8000 Fix translated message showing original text in message actions overl… · GetStream/stream-chat-swiftui@fb71e2c · GitHub
[go: up one dir, main page]

Skip to content

Commit fb71e2c

Browse files
authored
Fix translated message showing original text in message actions overlay (#810)
1 parent 3f4b97d commit fb71e2c

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010
- Fix having message edit action on Giphy messages [#806](https://github.com/GetStream/stream-chat-swiftui/pull/806)
1111
- Fix being able to long press an unsent Giphy message [#806](https://github.com/GetStream/stream-chat-swiftui/pull/806)
1212
- Fix being able to swipe to reply an unsent Giphy message [#806](https://github.com/GetStream/stream-chat-swiftui/pull/806)
13+
- Fix translated message showing original text in message actions overlay [#810](https://github.com/GetStream/stream-chat-swiftui/pull/810)
14+
1315
### 🔄 Changed
1416
- Deprecated `ComposerConfig.attachmentPayloadConverter` in favour of `MessageComposerViewModel.convertAddedAssetsToPayloads()` [#806](https://github.com/GetStream/stream-chat-swiftui/pull/806)
1517

Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayView.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,13 @@ public struct ReactionsOverlayView<Factory: ViewFactory>: View {
111111
Group {
112112
if messageDisplayInfo.frame.height > messageContainerHeight {
113113
< 8000 span class=pl-en>ScrollView {
114-
MessageView(
115-
factory: factory,
116-
message: messageDisplayInfo.message,
117-
contentWidth: messageDisplayInfo.contentWidth,
118-
isFirst: messageDisplayInfo.isFirst,
119-
scrolledId: .constant(nil)
120-
)
114+
messageView
121115
}
122116
} else {
123-
MessageView(
124-
factory: factory,
125-
message: messageDisplayInfo.message,
126-
contentWidth: messageDisplayInfo.contentWidth,
127-
isFirst: messageDisplayInfo.isFirst,
128-
scrolledId: .constant(nil)
129-
)
117+
messageView
130118
}
131119
}
120+
.environment(\.channelTranslationLanguage, channel.membership?.language)
132121
.scaleEffect(popIn || willPopOut ? 1 : 0.95) 8000
133122
.animation(willPopOut ? .easeInOut : popInAnimation, value: popIn)
134123
.offset(
@@ -228,6 +217,16 @@ public struct ReactionsOverlayView<Factory: ViewFactory>: View {
228217
}
229218
}
230219

220+
private var messageView: some View {
221+
MessageView(
222+
factory: factory,
223+
message: messageDisplayInfo.message,
224+
contentWidth: messageDisplayInfo.contentWidth,
225+
isFirst: messageDisplayInfo.isFirst,
226+
scrolledId: .constant(nil)
227+
)
228+
}
229+
231230
private func dismissReactionsOverlay(completion: @escaping () -> Void) {
232231
withAnimation {
233232
willPopOut = true

StreamChatSwiftUITests/Tests/ChatChannel/ReactionsOverlayView_Tests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,36 @@ class ReactionsOverlayView_Tests: StreamChatTestCase {
225225
// Then
226226
XCTAssert(offset == 12.5)
227227
}
228+
229+
func test_reactionsOverlayView_translated() {
230+
// Given
231+
let testMessage = ChatMessage.mock(
232+
id: "test",
233+
cid: .unique,
234+
text: "Hello",
235+
author: .mock(id: "test", name: "martin"),
236+
translations: [.portuguese: "Olá"]
237+
)
238+
let messageDisplayInfo = MessageDisplayInfo(
239+
message: testMessage,
240+
frame: self.messageDisplayInfo.frame,
241+
contentWidth: self.messageDisplayInfo.contentWidth,
242+
isFirst: true
243+
)
244+
let view = VerticallyCenteredView {
245+
ReactionsOverlayView(
246+
factory: DefaultViewFactory.shared,
247+
channel: .mock(cid: .unique, membership: .mock(id: "test", language: .portuguese)),
248+
currentSnapshot: self.overlayImage,
249+
messageDisplayInfo: messageDisplayInfo,
250+
onBackgroundTap: {},
251+
onActionExecuted: { _ in }
252+
)
253+
}
254+
255+
// Then
256+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
257+
}
228258
}
229259

230260
struct VerticallyCenteredView<Content: View>: View {

0 commit comments

Comments
 (0)
0