diff --git a/retroshare-qml-app/src/GxsIdentityDelegate.qml b/retroshare-qml-app/src/GxsIdentityDelegate.qml index 2b8142cf3..41ad5454f 100644 --- a/retroshare-qml-app/src/GxsIdentityDelegate.qml +++ b/retroshare-qml-app/src/GxsIdentityDelegate.qml @@ -91,22 +91,18 @@ Item color: "transparent" anchors.margins: 5 - - ColorHash + AvatarOrColorHash { id: colorHash - hash: model.gxs_id + gxs_id: model.gxs_id + height: parent.height - 4 anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: 2 - MouseArea - { - anchors.fill: parent - onClicked: delegateRoot.showDetails() - } + onlyCached: true } Column diff --git a/retroshare-qml-app/src/components/AvatarOrColorHash.qml b/retroshare-qml-app/src/components/AvatarOrColorHash.qml index b50002687..35eb30efd 100644 --- a/retroshare-qml-app/src/components/AvatarOrColorHash.qml +++ b/retroshare-qml-app/src/components/AvatarOrColorHash.qml @@ -25,6 +25,7 @@ Item id: compRoot property string gxs_id + property bool onlyCached: false signal clicked () height: 130 @@ -54,15 +55,14 @@ Item function(par) { var jData = JSON.parse(par.response).data - ChatCache.contactsCache.setIdentityDetails(jData) - setDetails(jData) + saveDetails(jData) if(!compRoot.has_avatar && compRoot.avatarAttemptCnt < 3) getDetails() }) } else { - setDetails(ChatCache.contactsCache.getIdentityDetails(gxs_id)) + setImage(ChatCache.contactsCache.getIdentityDetails(gxs_id)) } } else @@ -72,12 +72,19 @@ Item contactAvatar.source = noGxsImage } } - function setDetails(data) + function saveDetails(data) + { + ChatCache.contactsCache.setIdentityDetails(data) + setImage(data) + + } + function setImage (data) { compRoot.has_avatar = hasAvatar (data.avatar) if(compRoot.has_avatar) { - setImage(data.avatar) + contactAvatar.source = + "data:image/png;base64," + data.avatar } } @@ -85,11 +92,6 @@ Item { return avatar.length > 0 } - function setImage (source) - { - contactAvatar.source = - "data:image/png;base64," + source - } function showDetails() { @@ -100,9 +102,23 @@ Item {md: ChatCache.contactsCache.getContactFromGxsId(gxs_id)}) } - Component.onCompleted: if(visible && (!has_avatar || default_image ) ) getDetails() + Component.onCompleted: startComponent () - onVisibleChanged: if(visible && (!has_avatar || default_image ) ) getDetails() + onVisibleChanged: startComponent () + + function startComponent () + { + if (onlyCached && hasAvatar (ChatCache.contactsCache.getIdentityAvatar(gxs_id) ) ) + { + console.log("load cached avatar") + setImage(ChatCache.contactsCache.getIdentityDetails(gxs_id)) + + } + else if (!onlyCached) + { + if(visible && (!has_avatar || default_image ) ) getDetails() + } + } Image {