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 () { ...@@ -41,7 +41,7 @@ function getIsComposingMessage () {
var sipAddressObserver = chat.sipAddressObserver var sipAddressObserver = chat.sipAddressObserver
return qsTr('isComposing').replace( return qsTr('isComposing').replace(
'%1', '%1',
LinphoneUtils.getContactUsername(sipAddressObserver.contact || sipAddressObserver.sipAddress) LinphoneUtils.getContactUsername(sipAddressObserver)
) )
} }
......
...@@ -27,7 +27,7 @@ Row { ...@@ -27,7 +27,7 @@ Row {
width: ChatStyle.entry.message.incoming.avatarSize width: ChatStyle.entry.message.incoming.avatarSize
image: chat.sipAddressObserver.contact ? chat.sipAddressObserver.contact.avatar : '' 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 { ...@@ -21,7 +21,7 @@ RowLayout {
anchors.centerIn: parent anchors.centerIn: parent
height: ChatStyle.entry.message.incoming.avatarSize height: ChatStyle.entry.message.incoming.avatarSize
image: chat.sipAddressObserver.contact ? chat.sipAddressObserver.contact.vcard.avatar : '' 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 width: ChatStyle.entry.message.incoming.avatarSize
// The avatar is only visible for the first message of a incoming messages sequence. // The avatar is only visible for the first message of a incoming messages sequence.
......
...@@ -8,9 +8,16 @@ ...@@ -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) { function getContactUsername (contact) {
return Utils.isString(contact) var object = contact.contact || // Contact object from `SipAddressObserver`.
? contact.substring(4, contact.indexOf('@')) // 4 = length('sip:') (contact.vcard && contact) || // Contact object.
: contact.vcard.username (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 { ...@@ -41,7 +41,7 @@ Rectangle {
height: CallStyle.header.contactDescription.height height: CallStyle.header.contactDescription.height
horizontalTextAlignment: Text.AlignHCenter horizontalTextAlignment: Text.AlignHCenter
sipAddress: call.sipAddress sipAddress: call.sipAddress
username: LinphoneUtils.getContactUsername(_sipAddressObserver.contact || call.sipAddress) username: LinphoneUtils.getContactUsername(_sipAddressObserver)
width: parent.width width: parent.width
} }
......
...@@ -132,7 +132,7 @@ Rectangle { ...@@ -132,7 +132,7 @@ Rectangle {
horizontalTextAlignment: Text.AlignHCenter horizontalTextAlignment: Text.AlignHCenter
sipAddress: parent.sipAddressObserver.sipAddress sipAddress: parent.sipAddressObserver.sipAddress
username: LinphoneUtils.getContactUsername(parent.sipAddressObserver.contact || parent.sipAddress) username: LinphoneUtils.getContactUsername(parent.sipAddressObserver)
} }
IncallAvatar { IncallAvatar {
......
...@@ -38,7 +38,7 @@ Rectangle { ...@@ -38,7 +38,7 @@ Rectangle {
horizontalTextAlignment: Text.AlignHCenter horizontalTextAlignment: Text.AlignHCenter
sipAddress: _sipAddressObserver.sipAddress sipAddress: _sipAddressObserver.sipAddress
username: LinphoneUtils.getContactUsername(_sipAddressObserver.contact || sipAddress) username: LinphoneUtils.getContactUsername(_sipAddressObserver)
} }
Text { Text {
......
...@@ -144,7 +144,7 @@ Rectangle { ...@@ -144,7 +144,7 @@ Rectangle {
anchors.centerIn: parent anchors.centerIn: parent
horizontalTextAlignment: Text.AlignHCenter horizontalTextAlignment: Text.AlignHCenter
sipAddress: '' sipAddress: ''
username: LinphoneUtils.getContactUsername(_sipAddressObserver.contact || _sipAddressObserver.sipAddress) username: LinphoneUtils.getContactUsername(_sipAddressObserver)
height: parent.height height: parent.height
width: parent.width - rightActions.width - leftActions.width - CallStyle.header.contactDescription.width width: parent.width - rightActions.width - leftActions.width - CallStyle.header.contactDescription.width
......
...@@ -11,7 +11,7 @@ Avatar { ...@@ -11,7 +11,7 @@ Avatar {
property var call property var call
readonly property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.sipAddress) 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 backgroundColor: CallStyle.container.avatar.backgroundColor
foregroundColor: call.status === CallModel.CallStatusPaused foregroundColor: call.status === CallModel.CallStatusPaused
......
...@@ -29,10 +29,7 @@ function getEditIcon () { ...@@ -29,10 +29,7 @@ function getEditIcon () {
} }
function getUsername () { function getUsername () {
return LinphoneUtils.getContactUsername( return LinphoneUtils.getContactUsername(conversation._sipAddressObserver)
conversation._sipAddressObserver.contact ||
conversation.sipAddress
)
} }
function updateChatFilter (button) { 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