Skip to content

Commit

Permalink
Fix crash in media gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Jan 3, 2025
1 parent fce545f commit 5eff626
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Monal/Classes/MediaGallery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ struct ImageViewerWrapper: View {

var body: some View {
Group {
if let _ = info["mimeType"] as? String {
if let _ = info["mimeType"] as? String, (info["needsDownloading"] as! NSNumber).boolValue != true {
try? ImageViewer(delegate: dismisser, info: info)
} else {
Text("Invalid file data")
Expand Down
8 changes: 6 additions & 2 deletions Monal/Classes/chatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,10 @@ -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
} else {
dispatch_async(dispatch_get_main_queue(), ^{
NSDictionary* selectedItem = [MLFiletransfer getFileInfoForMessage:[self.messageList objectAtIndex:indexPath.row]];
NSMutableArray* allItems = [[DataLayer sharedInstance] allAttachmentsFromContact:self.contact.contactJid forAccount:self.contact.accountID];
NSMutableArray* allItems = [NSMutableArray new];
for(NSDictionary* info in [[DataLayer sharedInstance] allAttachmentsFromContact:self.contact.contactJid forAccount:self.contact.accountID])
if(!(((NSNumber*)nilDefault(info["needsDownloading"], YES)).boolValue) && ([info[@"mimeType"] hasPrefix:@"image/"] || [info[@"mimeType"] hasPrefix:@"video/"])
[allItems addObject:entry];
UIViewController* imageViewer = [[SwiftuiInterface new] makeImageViewerForCurrentItem:selectedItem allItems:allItems];
imageViewer.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:imageViewer animated:YES completion:^{}];
Expand All @@ -2388,7 +2391,8 @@ -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}

-(void) closePhotos {
-(void) closePhotos
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

Expand Down

0 comments on commit 5eff626

Please sign in to comment.