mirror of
				https://github.com/nerzhul/ocsms.git
				synced 2025-10-28 00:49:11 +00:00 
			
		
		
		
	Fix avatars in contact list
This commit is contained in:
		
							parent
							
								
									6c37d0ccfe
								
							
						
					
					
						commit
						b9fba16893
					
				| @ -320,13 +320,9 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' | |||||||
| 
 | 
 | ||||||
| 		$scope.fetchInitialPeerList = function (jsondata) { | 		$scope.fetchInitialPeerList = function (jsondata) { | ||||||
| 			// Use a buffer for better jQuery performance
 | 			// Use a buffer for better jQuery performance
 | ||||||
| 			var photoPrefix = ""; |  | ||||||
| 			var bufferedContacts = []; | 			var bufferedContacts = []; | ||||||
| 
 | 
 | ||||||
| 			$scope.photoVersion = jsondata["photo_version"]; | 			$scope.photoVersion = jsondata["photo_version"]; | ||||||
| 			if ($scope.photoVersion >= 2) { |  | ||||||
| 				photoPrefix = "data:image/png;base64,"; |  | ||||||
| 			} |  | ||||||
| 
 | 
 | ||||||
| 			$.each(jsondata['phonelist'], function(id, val) { | 			$.each(jsondata['phonelist'], function(id, val) { | ||||||
| 				var peerLabel, idxVal, idxVal2; | 				var peerLabel, idxVal, idxVal2; | ||||||
| @ -347,7 +343,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' | |||||||
| 					}; | 					}; | ||||||
| 
 | 
 | ||||||
| 					if (typeof(jsondata['photos'][peerLabel]) != 'undefined') { | 					if (typeof(jsondata['photos'][peerLabel]) != 'undefined') { | ||||||
| 						contactObj['avatar'] = photoPrefix + jsondata['photos'][peerLabel]; | 						contactObj['avatar'] = jsondata['photos'][peerLabel]; | ||||||
| 					} | 					} | ||||||
| 					$scope.addContact(contactObj); | 					$scope.addContact(contactObj); | ||||||
| 					bufferedContacts.push(peerLabel); | 					bufferedContacts.push(peerLabel); | ||||||
| @ -446,7 +442,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' | |||||||
| 						if ($scope.selectedContact.nav === undefined) { | 						if ($scope.selectedContact.nav === undefined) { | ||||||
| 							$scope.selectedContact.label = urlPhoneNumber; | 							$scope.selectedContact.label = urlPhoneNumber; | ||||||
| 							$scope.selectedContact.nav = urlPhoneNumber; | 							$scope.selectedContact.nav = urlPhoneNumber; | ||||||
| 							$scope.selectedContact.avatar = ""; | 							$scope.selectedContact.avatar = undefined; | ||||||
| 						} | 						} | ||||||
| 						$scope.fetchConversation(null); | 						$scope.fetchConversation(null); | ||||||
| 						changeSelectedConversation($("a[mailbox-navigation='" + urlPhoneNumber + "']")); | 						changeSelectedConversation($("a[mailbox-navigation='" + urlPhoneNumber + "']")); | ||||||
|  | |||||||
| @ -93,19 +93,13 @@ class ContactCache { | |||||||
| 				 | 				 | ||||||
| 				if (isset ($r["PHOTO"])) { | 				if (isset ($r["PHOTO"])) { | ||||||
| 					// Remove useless prefix
 | 					// Remove useless prefix
 | ||||||
| 					// @TODO detect owncloud version
 |  | ||||||
| 					$ocversion = \OCP\Util::getVersion(); | 					$ocversion = \OCP\Util::getVersion(); | ||||||
| 					$photoURL = preg_replace("#^VALUE=uri:#","",$r["PHOTO"], 1); | 					$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; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	private function pushPhoneNumberToCache($rawPhone, $contactName, $country) { | 	private function pushPhoneNumberToCache($rawPhone, $contactName, $country) { | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ use \OCA\OcSms\Lib\CountryCodes; | |||||||
| 	<div id="app-mailbox-peers"> | 	<div id="app-mailbox-peers"> | ||||||
| 		<ul class="contact-list"> | 		<ul class="contact-list"> | ||||||
| 			<li ng-repeat="contact in contacts | orderBy:'-lastmsg'" peer-label="{{ contact.label }}" ng-click="loadConversation(contact);" href="#"> | 			<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> | 				<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> | 				<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> | 			</li> | ||||||
| @ -49,8 +49,8 @@ use \OCA\OcSms\Lib\CountryCodes; | |||||||
| 		<div id="app-content-header" ng-show="selectedContact.label !== undefined && selectedContact.label !== ''" | 		<div id="app-content-header" ng-show="selectedContact.label !== undefined && selectedContact.label !== ''" | ||||||
| 			 ng-style="{'background-color': (selectedContact.label | peerColor)}"> | 			 ng-style="{'background-color': (selectedContact.label | peerColor)}"> | ||||||
| 			<div id="ocsms-contact-avatar"> | 			<div id="ocsms-contact-avatar"> | ||||||
| 				<img class="ocsms-plavatar-big" data-ng-src="data:image/png;base64,{{ selectedContact.avatar }}" | 				<img class="ocsms-plavatar-big" ng-src="{{ selectedContact.avatar }}" | ||||||
| 					 ng-show="selectedContact.avatar !== undefined && selectedContact.avatar != ''" /> | 					 ng-show="selectedContact.avatar !== undefined" /> | ||||||
| 			</div> | 			</div> | ||||||
| 			<div id="ocsms-contact-details"> | 			<div id="ocsms-contact-details"> | ||||||
| 				<div id="ocsms-phone-label">{{ selectedContact.label }} </div> | 				<div id="ocsms-phone-label">{{ selectedContact.label }} </div> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user