Skip to content

Commit

Permalink
Simplify avatar api
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Müller <[email protected]>
  • Loading branch information
SystemKeeper committed Mar 14, 2024
1 parent 52cdb23 commit b21e6fc
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions NextcloudTalk/AvatarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ import SDWebImage

// MARK: - Conversation avatars

public func setAvatar(for room: NCRoom, with style: UIUserInterfaceStyle) {
public func setAvatar(for room: NCRoom) {
self.cancelCurrentRequest()

self.currentRequest = AvatarManager.shared.getAvatar(for: room, with: style) { image in
self.currentRequest = AvatarManager.shared.getAvatar(for: room, with: self.traitCollection.userInterfaceStyle) { image in
guard let image = image else {
return
}
Expand All @@ -63,8 +63,8 @@ import SDWebImage
}
}

public func setGroupAvatar(with style: UIUserInterfaceStyle) {
if let image = AvatarManager.shared.getGroupAvatar(with: style) {
public func setGroupAvatar() {
if let image = AvatarManager.shared.getGroupAvatar(with: self.traitCollection.userInterfaceStyle) {
self.setImage(image, for: .normal)
}
}
Expand Down
12 changes: 6 additions & 6 deletions NextcloudTalk/AvatarImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ import SDWebImage

// MARK: - Conversation avatars

public func setAvatar(for room: NCRoom, with style: UIUserInterfaceStyle) {
public func setAvatar(for room: NCRoom) {
self.cancelCurrentRequest()

self.currentRequest = AvatarManager.shared.getAvatar(for: room, with: style) { image in
self.currentRequest = AvatarManager.shared.getAvatar(for: room, with: self.traitCollection.userInterfaceStyle) { image in
guard let image = image else {
return
}
Expand All @@ -61,14 +61,14 @@ import SDWebImage
}
}

public func setGroupAvatar(with style: UIUserInterfaceStyle) {
if let image = AvatarManager.shared.getGroupAvatar(with: style) {
public func setGroupAvatar() {
if let image = AvatarManager.shared.getGroupAvatar(with: self.traitCollection.userInterfaceStyle) {
self.image = image
}
}

public func setMailAvatar(with style: UIUserInterfaceStyle) {
if let image = AvatarManager.shared.getMailAvatar(with: style) {
public func setMailAvatar() {
if let image = AvatarManager.shared.getMailAvatar(with: self.traitCollection.userInterfaceStyle) {
self.image = image
}
}
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/NCChatTitleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ - (void)layoutSubviews
- (void)updateForRoom:(NCRoom *)room
{
// Set room image
[self.avatarimage setAvatarFor:room with:self.traitCollection.userInterfaceStyle];
[self.avatarimage setAvatarFor:room];

NSString *subtitle = nil;

Expand Down
4 changes: 2 additions & 2 deletions NextcloudTalk/OpenConversationsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ class OpenConversationsTableViewController: UITableViewController, UISearchResul

cell.labelTitle.text = openConversation.displayName
// Set group avatar as default avatar
cell.contactImage.setGroupAvatar(with: self.traitCollection.userInterfaceStyle)
cell.contactImage.setGroupAvatar()
// Try to get room avatar even though at the moment (Talk 17) it is not exposed
cell.contactImage.setAvatar(for: openConversation, with: self.traitCollection.userInterfaceStyle)
cell.contactImage.setAvatar(for: openConversation)

return cell
}
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/ReferenceTalkView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import SwiftyAttributes
let room = NCDatabaseManager.sharedInstance().room(withToken: roomToken, forAccountId: activeAccount.accountId)

if let room = room {
self.referenceTypeIcon.setAvatar(for: room, with: self.traitCollection.userInterfaceStyle)
self.referenceTypeIcon.setAvatar(for: room)
self.referenceTypeIcon.layer.cornerRadius = self.referenceTypeIcon.frame.height / 2
} else {
self.referenceTypeIcon.layer.cornerRadius = 0
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/RoomAvatarInfoTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ enum RoomAvatarInfoSection: Int {
}

func updateHeaderView() {
self.headerView.avatarImageView.setAvatar(for: self.room, with: self.traitCollection.userInterfaceStyle)
self.headerView.avatarImageView.setAvatar(for: self.room)

self.headerView.editView.isHidden = !NCDatabaseManager.sharedInstance().serverHasTalkCapability(kCapabilityConversationAvatars, forAccountId: self.room.accountId)
self.headerView.trashButton.isHidden = !self.room.isCustomAvatar
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/RoomCreationTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ enum RoomVisibilityOption: Int {
} else if self.selectedEmojiImage != nil {
self.headerView.avatarImageView.image = self.selectedEmojiImage
} else {
self.headerView.avatarImageView.setGroupAvatar(with: self.traitCollection.userInterfaceStyle)
self.headerView.avatarImageView.setGroupAvatar()
}

self.headerView.trashButton.isHidden = self.selectedAvatarImage == nil && self.selectedEmojiImage == nil
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/RoomInfoTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.roomNameTextField.text = _room.displayName;
}

[cell.roomImage setAvatarFor:_room with:self.traitCollection.userInterfaceStyle];
[cell.roomImage setAvatarFor:_room];

if (_room.hasCall) {
[cell.favoriteImage setTintColor:[UIColor systemRedColor]];
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/RoomSearchTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[cell setUnreadMessages:room.unreadMessages mentioned:mentioned groupMentioned:NO];
}

[cell.roomImage setAvatarFor:room with:self.traitCollection.userInterfaceStyle];
[cell.roomImage setAvatarFor:room];

// Set favorite or call image
if (room.hasCall) {
Expand Down
4 changes: 2 additions & 2 deletions NextcloudTalk/RoomsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.subtitleLabel.text = pendingInvitationsString;
cell.dateLabel.text = @"";

[cell.roomImage setMailAvatarWith:self.traitCollection.userInterfaceStyle];
[cell.roomImage setMailAvatar];

return cell;
}
Expand Down Expand Up @@ -1529,7 +1529,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[cell setUnreadMessages:room.unreadMessages mentioned:mentioned groupMentioned:NO];
}

[cell.roomImage setAvatarFor:room with:self.traitCollection.userInterfaceStyle];
[cell.roomImage setAvatarFor:room];

// Set favorite or call image
if (room.hasCall) {
Expand Down
2 changes: 1 addition & 1 deletion ShareExtension/ShareViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

cell.titleLabel.text = room.displayName;

[cell.avatarImageView setAvatarFor:room with:self.traitCollection.userInterfaceStyle];
[cell.avatarImageView setAvatarFor:room];

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

Expand Down

0 comments on commit b21e6fc

Please sign in to comment.