Skip to content

Commit

Permalink
Merge pull request #1375 from nextcloud/fix-avatar-crash-ios-17
Browse files Browse the repository at this point in the history
Fix crash on iOS 17 when avatar was not downloaded before
  • Loading branch information
Ivansss committed Sep 27, 2023
2 parents 9899ace + d0d369c commit 81f634a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions NextcloudTalk/NCCameraController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ class NCCameraController: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate
self.session?.sessionPreset = .inputPriority

if self.usingFrontCamera {
self.session?.addInput(getFrontCameraInput())
self.session?.addInput(self.getFrontCameraInput())
} else {
self.session?.addInput(getBackCameraInput())
self.session?.addInput(self.getBackCameraInput())
}

let output = AVCaptureVideoDataOutput()
Expand Down
25 changes: 14 additions & 11 deletions NextcloudTalk/RoomsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -439,21 +439,24 @@ - (void)updateAccountPickerMenu
for (TalkAccount *account in [[NCDatabaseManager sharedInstance] allAccounts]) {
NSString *accountName = account.userDisplayName;
UIImage *accountImage = [[NCAPIController sharedInstance] userProfileImageForAccount:account withStyle:self.traitCollection.userInterfaceStyle];
accountImage = [NCUtils roundedImageFromImage:accountImage];

// Draw a red circle to the image in case we have unread notifications for that account
if (account.unreadNotification) {
UIGraphicsBeginImageContextWithOptions(CGSizeMake(82, 82), NO, 3);
CGContextRef context = UIGraphicsGetCurrentContext();
[accountImage drawInRect:CGRectMake(0, 4, 78, 78)];
CGContextSaveGState(context);
if (accountImage) {
accountImage = [NCUtils roundedImageFromImage:accountImage];

CGContextSetFillColorWithColor(context, [UIColor systemRedColor].CGColor);
CGContextFillEllipseInRect(context, CGRectMake(52, 0, 30, 30));
// Draw a red circle to the image in case we have unread notifications for that account
if (account.unreadNotification) {
UIGraphicsBeginImageContextWithOptions(CGSizeMake(82, 82), NO, 3);
CGContextRef context = UIGraphicsGetCurrentContext();
[accountImage drawInRect:CGRectMake(0, 4, 78, 78)];
CGContextSaveGState(context);

accountImage = UIGraphicsGetImageFromCurrentImageContext();
CGContextSetFillColorWithColor(context, [UIColor systemRedColor].CGColor);
CGContextFillEllipseInRect(context, CGRectMake(52, 0, 30, 30));

UIGraphicsEndImageContext();
accountImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();
}
}

UIAction *switchAccountAction = [UIAction actionWithTitle:accountName image:accountImage identifier:nil handler:^(UIAction *action) {
Expand Down

0 comments on commit 81f634a

Please sign in to comment.