Merge pull request #2794 from vector-im/fix_tap_attachment_sent_failed_crash

RoomVC: Fix crash occurring when tap on an unsent media with retrieved event equal to nil
This commit is contained in:
SBiOSoftWhare 2019-10-22 12:18:02 +02:00 committed by GitHub
commit b4890085bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -4,6 +4,7 @@ Changes in 0.10.1 (2019-XX-XX)
Bug fix: Bug fix:
* Room cell: The states of direct chat and favorite buttons are reversed in the menu (#2788). * Room cell: The states of direct chat and favorite buttons are reversed in the menu (#2788).
* Pasteboard: Fix a crash when passing a nil object to UIPasteboard. * Pasteboard: Fix a crash when passing a nil object to UIPasteboard.
* RoomVC: Fix crash occurring when tap on an unsent media with retrieved event equal to nil.
Changes in 0.10.0 (2019-10-11) Changes in 0.10.0 (2019-10-11)
=============================================== ===============================================

View file

@ -2259,9 +2259,18 @@
if (((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.eventSentState == MXEventSentStateFailed) if (((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.eventSentState == MXEventSentStateFailed)
{ {
// Shortcut: when clicking on an unsent media, show the action sheet to resend it // Shortcut: when clicking on an unsent media, show the action sheet to resend it
MXEvent *selectedEvent = [self.roomDataSource eventWithEventId:((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.eventId]; NSString *eventId = ((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.eventId;
MXEvent *selectedEvent = [self.roomDataSource eventWithEventId:eventId];
if (selectedEvent)
{
[self dataSource:dataSource didRecognizeAction:kMXKRoomBubbleCellRiotEditButtonPressed inCell:cell userInfo:@{kMXKRoomBubbleCellEventKey:selectedEvent}]; [self dataSource:dataSource didRecognizeAction:kMXKRoomBubbleCellRiotEditButtonPressed inCell:cell userInfo:@{kMXKRoomBubbleCellEventKey:selectedEvent}];
} }
else
{
NSLog(@"[RoomViewController] didRecognizeAction:inCell:userInfo tap on attachment with event state MXEventSentStateFailed. Selected event is nil for event id %@", eventId);
}
}
else if (((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.type == MXKAttachmentTypeSticker) else if (((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.type == MXKAttachmentTypeSticker)
{ {
// We don't open the attachments viewer when the user taps on a sticker. // We don't open the attachments viewer when the user taps on a sticker.