Skip to content

Commit 5eff626

Browse files
Fix crash in media gallery
1 parent fce545f commit 5eff626

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Monal/Classes/MediaGallery.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct ImageViewerWrapper: View {
204204

205205
var body: some View {
206206
Group {
207-
if let _ = info["mimeType"] as? String {
207+
if let _ = info["mimeType"] as? String, (info["needsDownloading"] as! NSNumber).boolValue != true {
208208
try? ImageViewer(delegate: dismisser, info: info)
209209
} else {
210210
Text("Invalid file data")

Monal/Classes/chatViewController.m

+6-2
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,10 @@ -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
23782378
} else {
23792379
dispatch_async(dispatch_get_main_queue(), ^{
23802380
NSDictionary* selectedItem = [MLFiletransfer getFileInfoForMessage:[self.messageList objectAtIndex:indexPath.row]];
2381-
NSMutableArray* allItems = [[DataLayer sharedInstance] allAttachmentsFromContact:self.contact.contactJid forAccount:self.contact.accountID];
2381+
NSMutableArray* allItems = [NSMutableArray new];
2382+
for(NSDictionary* info in [[DataLayer sharedInstance] allAttachmentsFromContact:self.contact.contactJid forAccount:self.contact.accountID])
2383+
if(!(((NSNumber*)nilDefault(info["needsDownloading"], YES)).boolValue) && ([info[@"mimeType"] hasPrefix:@"image/"] || [info[@"mimeType"] hasPrefix:@"video/"])
2384+
[allItems addObject:entry];
23822385
UIViewController* imageViewer = [[SwiftuiInterface new] makeImageViewerForCurrentItem:selectedItem allItems:allItems];
23832386
imageViewer.modalPresentationStyle = UIModalPresentationOverFullScreen;
23842387
[self presentViewController:imageViewer animated:YES completion:^{}];
@@ -2388,7 +2391,8 @@ -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
23882391
}
23892392
}
23902393

2391-
-(void) closePhotos {
2394+
-(void) closePhotos
2395+
{
23922396
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
23932397
}
23942398

0 commit comments

Comments
 (0)