1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-07-22 17:35:52 +00:00

Fix avatars in contact list

This commit is contained in:
Loic Blot 2016-09-19 22:25:21 +02:00
parent 6c37d0ccfe
commit b9fba16893
3 changed files with 6 additions and 16 deletions

View File

@ -320,13 +320,9 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
$scope.fetchInitialPeerList = function (jsondata) {
// Use a buffer for better jQuery performance
var photoPrefix = "";
var bufferedContacts = [];
$scope.photoVersion = jsondata["photo_version"];
if ($scope.photoVersion >= 2) {
photoPrefix = "data:image/png;base64,";
}
$.each(jsondata['phonelist'], function(id, val) {
var peerLabel, idxVal, idxVal2;
@ -347,7 +343,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
};
if (typeof(jsondata['photos'][peerLabel]) != 'undefined') {
contactObj['avatar'] = photoPrefix + jsondata['photos'][peerLabel];
contactObj['avatar'] = jsondata['photos'][peerLabel];
}
$scope.addContact(contactObj);
bufferedContacts.push(peerLabel);
@ -446,7 +442,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
if ($scope.selectedContact.nav === undefined) {
$scope.selectedContact.label = urlPhoneNumber;
$scope.selectedContact.nav = urlPhoneNumber;
$scope.selectedContact.avatar = "";
$scope.selectedContact.avatar = undefined;
}
$scope.fetchConversation(null);
changeSelectedConversation($("a[mailbox-navigation='" + urlPhoneNumber + "']"));

View File

@ -93,15 +93,9 @@ class ContactCache {
if (isset ($r["PHOTO"])) {
// Remove useless prefix
// @TODO detect owncloud version
$ocversion = \OCP\Util::getVersion();
$photoURL = preg_replace("#^VALUE=uri:#","",$r["PHOTO"], 1);
if (version_compare($ocversion[0].".".$ocversion[1].".".$ocversion[2], "9.0.0", ">=")) {
$this->contactPhotos[$r["FN"]] = base64_encode($photoURL);
}
else {
$this->contactPhotos[$r["FN"]] = $photoURL;
}
$this->contactPhotos[$r["FN"]] = $photoURL;
}
}
}

View File

@ -10,7 +10,7 @@ use \OCA\OcSms\Lib\CountryCodes;
<div id="app-mailbox-peers">
<ul class="contact-list">
<li ng-repeat="contact in contacts | orderBy:'-lastmsg'" peer-label="{{ contact.label }}" ng-click="loadConversation(contact);" href="#">
<img class="ocsms-plavatar" data-ng-src="data:image/png;base64,{{ contact.avatar }}" ng-show="contact.avatar !== undefined" />
<img class="ocsms-plavatar" ng-src="{{ contact.avatar }}" ng-show="contact.avatar !== undefined" />
<div class="ocsms-plavatar" ng-show="contact.avatar === undefined" ng-style="{'background-color': (contact.label | peerColor)}">{{ contact.label | firstCharacter }}</div>
<a class="ocsms-plname" style="{{ contact.unread > 0 ? 'font-weight:bold;' : ''}}" mailbox-label="{{ contact.label }}" mailbox-navigation="{{ contact.nav }}">{{ contact.label }}{{ contact.unread > 0 ? ' (' + contact.unread + ') ' : '' }}</a>
</li>
@ -49,8 +49,8 @@ use \OCA\OcSms\Lib\CountryCodes;
<div id="app-content-header" ng-show="selectedContact.label !== undefined && selectedContact.label !== ''"
ng-style="{'background-color': (selectedContact.label | peerColor)}">
<div id="ocsms-contact-avatar">
<img class="ocsms-plavatar-big" data-ng-src="data:image/png;base64,{{ selectedContact.avatar }}"
ng-show="selectedContact.avatar !== undefined && selectedContact.avatar != ''" />
<img class="ocsms-plavatar-big" ng-src="{{ selectedContact.avatar }}"
ng-show="selectedContact.avatar !== undefined" />
</div>
<div id="ocsms-contact-details">
<div id="ocsms-phone-label">{{ selectedContact.label }} </div>