Skip to content

Commit c7f7f37

Browse files
Fix message long press taking too much time to show actions (#648)
* Add high priority gesture to message long press * Update CHANGELOG.md * Trying to fix the flaky assertion * Test fix * Test * Revert this commit * Revert "Revert this commit" This reverts commit 030fa4f. * Revert this commit * Test long sleep * Revert "Revert this commit" This reverts commit 96090d3. * Update the test --------- Co-authored-by: Alexey Alter-Pesotskiy <[email protected]>
1 parent b1a685a commit c7f7f37

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

CHANGELOG.md

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

44
# Upcoming
55

6+
### 🐞 Fixed
7+
- Fix message long press taking too much time to show actions [#648](https://github.com/GetStream/stream-chat-swiftui/pull/648)
68
### 🔄 Changed
79
- Message composer now uses `.uploadFile` capability when showing attachment picker icon [#646](https://github.com/GetStream/stream-chat-swiftui/pull/646)
810
- `ChannelInfoView` now uses `.updateChannelMembers` capability to show "Add Users" button [#651](https://github.com/GetStream/stream-chat-swiftui/pull/651)

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageContainerView.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
121121
handleGestureForMessage(showsMessageActions: true)
122122
}
123123
}
124-
.onLongPressGesture(perform: {
125-
if !message.isDeleted {
126-
handleGestureForMessage(showsMessageActions: true)
127-
}
128-
})
124+
.highPriorityGesture(
125+
LongPressGesture()
126+
.onEnded { _ in
127+
if !message.isDeleted {
128+
handleGestureForMessage(showsMessageActions: true)
129+
}
130+
}
131+
)
129132
.offset(x: min(self.offsetX, maximumHorizontalSwipeDisplacement))
130133
.simultaneousGesture(
131134
DragGesture(

StreamChatSwiftUITestsAppTests/Robots/UserRobot+Asserts.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -931,22 +931,12 @@ extension UserRobot {
931931
let image = attributes.image(in: messageCell)
932932
if isPresent {
933933
image.wait()
934-
sleep(2) // At the moment, this assert is flaky without it
935934
} else {
936935
image.waitForDisappearance()
937936
}
938937

939938
let errMessage = isPresent ? "Image is not presented" : "Image is presented"
940-
XCTAssertTrue(image.exists, errMessage, file: file, line: line)
941-
942-
image.safeTap()
943-
image.waitForDisappearance(timeout: 2)
944-
if image.exists {
945-
image.safeTap()
946-
}
947-
948-
let fullscreenImage = attributes.fullscreenImage().wait()
949-
XCTAssertTrue(fullscreenImage.exists, "Fullscreen \(errMessage)", file: file, line: line)
939+
XCTAssertEqual(isPresent, image.exists, errMessage, file: file, line: line)
950940
return self
951941
}
952942

0 commit comments

Comments
 (0)