Skip to content

Commit 9c16a7a

Browse files
Safe unwrapping of current graphics context when showing reactions
1 parent f9752d7 commit 9c16a7a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1414
### 🐞 Fixed
1515
- Channel header sometimes blinks when many messages are sent
1616
- Data race when channels are updated from message list
17+
- Safe unwrapping of current graphics context when showing reactions
1718

1819
# [4.20.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.20.0)
1920
_August 04, 2022_

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelViewModel.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,12 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
231231
return
232232
}
233233
UIGraphicsBeginImageContext(view.frame.size)
234-
view.layer.render(in: UIGraphicsGetCurrentContext()!)
235-
currentSnapshot = UIGraphicsGetImageFromCurrentImageContext()
234+
if let currentGraphicsContext = UIGraphicsGetCurrentContext() {
235+
view.layer.render(in: currentGraphicsContext)
236+
currentSnapshot = UIGraphicsGetImageFromCurrentImageContext()
237+
} else {
238+
currentSnapshot = images.snapshot
239+
}
236240
UIGraphicsEndImageContext()
237241
}
238242

0 commit comments

Comments
 (0)