Skip to content

Commit 6a522fc

Browse files
authored
Reduce view updates when computing frame for long press action (#607)
1 parent 3d7a554 commit 6a522fc

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

CHANGELOG.md

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

44
# Upcoming
55

6-
### 🔄 Changed
6+
### 🐞 Fixed
7+
- Rare crash when accessing frame of the view [#607](https://github.com/GetStream/stream-chat-swiftui/pull/607)
78

89
# [4.63.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.63.0)
910
_September 12, 2024_

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageContainerView.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
112112
GeometryReader { proxy in
113113
Rectangle().fill(Color.clear)
114114
.onChange(of: computeFrame, perform: { _ in
115-
DispatchQueue.main.async {
116-
frame = proxy.frame(in: .global)
117-
}
115+
frame = proxy.frame(in: .global)
118116
})
119117
}
120118
)
@@ -347,9 +345,8 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
347345
showsMessageActions: Bool,
348346
showsBottomContainer: Bool = true
349347
) {
350-
computeFrame = true
348+
computeFrame.toggle()
351349
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
352-
computeFrame = false
353350
triggerHapticFeedback(style: .medium)
354351
onLongPress(
355352
MessageDisplayInfo(

0 commit comments

Comments
 (0)