Commit 0c0b8c4f authored by Wescoeur's avatar Wescoeur

feat(LinphoneUtils): `getContactUsername` is now magic, it supports sipAddressObserver

parent b74f36a7
......@@ -41,7 +41,7 @@ function getIsComposingMessage () {
var sipAddressObserver = chat.sipAddressObserver
return qsTr('isComposing').replace(
'%1',
LinphoneUtils.getContactUsername(sipAddressObserver.contact || sipAddressObserver.sipAddress)
LinphoneUtils.getContactUsername(sipAddressObserver)
)
}
......
......@@ -27,7 +27,7 @@ Row {
width: ChatStyle.entry.message.incoming.avatarSize
image: chat.sipAddressObserver.contact ? chat.sipAddressObserver.contact.avatar : ''
username: LinphoneUtils.getContactUsername(chat.sipAddressObserver.contact || proxyModel.sipAddress)
username: LinphoneUtils.getContactUsername(chat.sipAddressObserver)
}
}
......
......@@ -21,7 +21,7 @@ RowLayout {
anchors.centerIn: parent
height: ChatStyle.entry.message.incoming.avatarSize
image: chat.sipAddressObserver.contact ? chat.sipAddressObserver.contact.vcard.avatar : ''
username: LinphoneUtils.getContactUsername(chat.sipAddressObserver.contact || proxyModel.sipAddress)
username: LinphoneUtils.getContactUsername(chat.sipAddressObserver)
width: ChatStyle.entry.message.incoming.avatarSize
// The avatar is only visible for the first message of a incoming messages sequence.
......
......@@ -8,9 +8,16 @@
// =============================================================================
// Returns the username of a contact object or URI string.
// Returns the username of a contact/sipAddressObserver object or URI string.
function getContactUsername (contact) {
return Utils.isString(contact)
? contact.substring(4, contact.indexOf('@')) // 4 = length('sip:')
: contact.vcard.username
var object = contact.contact || // Contact object from `SipAddressObserver`.
(contact.vcard && contact) || // Contact object.
(contact.sipAddress) || // String from `SipAddressObserver`.
contact // String.
if (Utils.isString(object)) {
return object.substring(4, object.indexOf('@')) // 4 = length('sip:')
}
return object.vcard.username
}
......@@ -41,7 +41,7 @@ Rectangle {
height: CallStyle.header.contactDescription.height
horizontalTextAlignment: Text.AlignHCenter
sipAddress: call.sipAddress
username: LinphoneUtils.getContactUsername(_sipAddressObserver.contact || call.sipAddress)
username: LinphoneUtils.getContactUsername(_sipAddressObserver)
width: parent.width
}
......
......@@ -132,7 +132,7 @@ Rectangle {
horizontalTextAlignment: Text.AlignHCenter
sipAddress: parent.sipAddressObserver.sipAddress
username: LinphoneUtils.getContactUsername(parent.sipAddressObserver.contact || parent.sipAddress)
username: LinphoneUtils.getContactUsername(parent.sipAddressObserver)
}
IncallAvatar {
......
......@@ -38,7 +38,7 @@ Rectangle {
horizontalTextAlignment: Text.AlignHCenter
sipAddress: _sipAddressObserver.sipAddress
username: LinphoneUtils.getContactUsername(_sipAddressObserver.contact || sipAddress)
username: LinphoneUtils.getContactUsername(_sipAddressObserver)
}
Text {
......
......@@ -144,7 +144,7 @@ Rectangle {
anchors.centerIn: parent
horizontalTextAlignment: Text.AlignHCenter
sipAddress: ''
username: LinphoneUtils.getContactUsername(_sipAddressObserver.contact || _sipAddressObserver.sipAddress)
username: LinphoneUtils.getContactUsername(_sipAddressObserver)
height: parent.height
width: parent.width - rightActions.width - leftActions.width - CallStyle.header.contactDescription.width
......
......@@ -11,7 +11,7 @@ Avatar {
property var call
readonly property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.sipAddress)
readonly property var _username: LinphoneUtils.getContactUsername(_sipAddressObserver.contact || call.sipAddress)
readonly property var _username: LinphoneUtils.getContactUsername(_sipAddressObserver)
backgroundColor: CallStyle.container.avatar.backgroundColor
foregroundColor: call.status === CallModel.CallStatusPaused
......
......@@ -29,10 +29,7 @@ function getEditIcon () {
}
function getUsername () {
return LinphoneUtils.getContactUsername(
conversation._sipAddressObserver.contact ||
conversation.sipAddress
)
return LinphoneUtils.getContactUsername(conversation._sipAddressObserver)
}
function updateChatFilter (button) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment