forked from mirrors/linphone-iphone
FIx avatar in conversation list
This commit is contained in:
parent
5beb5c088c
commit
d7a7615616
3 changed files with 21 additions and 21 deletions
|
|
@ -306,13 +306,12 @@ final class ContactsManager: ObservableObject {
|
|||
let clonedAddress = address.clone()
|
||||
clonedAddress!.clean()
|
||||
let sipUri = clonedAddress!.asStringUriOnly()
|
||||
|
||||
if friendList != nil {
|
||||
var friend: Friend?
|
||||
self.coreContext.doOnCoreQueue { _ in
|
||||
friend = self.friendList!.friends.first(where: {$0.addresses.contains(where: {$0.asStringUriOnly() == sipUri})})
|
||||
if friend == nil {
|
||||
friend = self.linphoneFriendList!.friends.first(where: {$0.addresses.contains(where: {$0.asStringUriOnly() == sipUri})})
|
||||
}
|
||||
friend = self.friendList!.friends.first(where: {$0.addresses.contains(where: {$0.asStringUriOnly() == sipUri})})
|
||||
if friend == nil {
|
||||
friend = self.linphoneFriendList!.friends.first(where: {$0.addresses.contains(where: {$0.asStringUriOnly() == sipUri})})
|
||||
}
|
||||
|
||||
return friend
|
||||
|
|
|
|||
|
|
@ -221,19 +221,15 @@ class ConversationModel: ObservableObject {
|
|||
|
||||
func refreshAvatarModel() {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
let addressFriend =
|
||||
(self.chatRoom.participants.first != nil && self.chatRoom.participants.first!.address != nil)
|
||||
? self.contactsManager.getFriendWithAddress(address: self.chatRoom.participants.first!.address!)
|
||||
: nil
|
||||
|
||||
if addressFriend != nil && !self.isGroup {
|
||||
let avatarModelTmp = ContactsManager.shared.avatarListModel.first(where: {
|
||||
$0.friend!.name == addressFriend!.name
|
||||
&& $0.friend!.address!.asStringUriOnly() == addressFriend!.address!.asStringUriOnly()
|
||||
}) ?? ContactAvatarModel(friend: nil, name: self.subject, withPresence: false)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.avatarModel = avatarModelTmp
|
||||
if !self.isGroup {
|
||||
if self.chatRoom.participants.first != nil && self.chatRoom.participants.first!.address != nil {
|
||||
let avatarModelTmp = ContactAvatarModel.getAvatarModelFromAddress(address: self.chatRoom.participants.first!.address!)
|
||||
let subjectTmp = avatarModelTmp.name
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.avatarModel = avatarModelTmp
|
||||
self.subject = subjectTmp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -242,7 +238,6 @@ class ConversationModel: ObservableObject {
|
|||
func downloadContent(chatMessage: ChatMessage, content: Content) {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
let result = chatMessage.downloadContent(content: content)
|
||||
print("resultresult download \(result)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,10 +183,16 @@ class ConversationViewModel: ObservableObject {
|
|||
if eventLog.chatMessage != nil && !eventLog.chatMessage!.contents.isEmpty {
|
||||
eventLog.chatMessage!.contents.forEach { content in
|
||||
if content.isText {
|
||||
print("contentscontents text")
|
||||
contentText = content.utf8Text ?? ""
|
||||
} else {
|
||||
print("contentscontents \(content.isText)")
|
||||
if content.filePath == nil || content.filePath!.isEmpty {
|
||||
self.downloadContent(chatMessage: eventLog.chatMessage!, content: content)
|
||||
} else {
|
||||
if URL(string: self.getNewFilePath(name: content.name ?? "")) != nil {
|
||||
let attachment = Attachment(id: UUID().uuidString, url: URL(string: self.getNewFilePath(name: content.name ?? ""))!, type: (content.name?.lowercased().hasSuffix("gif"))! ? .gif : .image)
|
||||
attachmentList.append(attachment)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue