Skip to content

Commit

Permalink
Fix crash on iOS 17 when avatar was not downloaded before
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Müller <[email protected]>
  • Loading branch information
SystemKeeper committed Sep 25, 2023
1 parent 778464a commit 314c794
Showing 1 changed file with 14 additions and 11 deletions.
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 314c794

Please sign in to comment.