Skip to content

Commit 3a0f20b

Browse files
committed
Return empty cell in case location is invalid
1 parent ba4f2b9 commit 3a0f20b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Sources/Views/Cells/LocationMessageCell.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ open class LocationMessageCell: MessageContentCell {
5858
and messagesCollectionView: MessagesCollectionView)
5959
{
6060
super.configure(with: message, at: indexPath, and: messagesCollectionView)
61+
62+
guard case .location(let locationItem) = message.kind else { fatalError("Configuring LocationMessageCell with wrong message kind") }
63+
guard CLLocationCoordinate2DIsValid(locationItem.location.coordinate) else {
64+
return
65+
}
66+
6167
guard let displayDelegate = messagesCollectionView.messagesDisplayDelegate else {
6268
fatalError(MessageKitError.nilMessagesDisplayDelegate)
6369
}
@@ -71,8 +77,6 @@ open class LocationMessageCell: MessageContentCell {
7177
at: indexPath,
7278
in: messagesCollectionView)
7379

74-
guard case .location(let locationItem) = message.kind else { fatalError("Configuring LocationMessageCell with wrong message kind") }
75-
7680
activityIndicator.startAnimating()
7781

7882
let snapshotOptions = MKMapSnapshotter.Options()

0 commit comments

Comments
 (0)