From 62046f307ff13b90bc53fdd37e0cca4f2dd7c27f Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 22 Jul 2014 12:36:49 +0400 Subject: [PATCH] Improved phonebook photos Closes #385 --- app/js/services.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/js/services.js b/app/js/services.js index 60a82a06..bfbcb857 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -320,7 +320,7 @@ angular.module('myApp.services', []) } }) -.service('PhonebookContactsService', function ($q, $modal, $sce) { +.service('PhonebookContactsService', function ($q, $modal, $sce, FileManager) { var phonebookContactsPromise; @@ -376,9 +376,12 @@ angular.module('myApp.services', []) contact.phones.push(this.result.tel[i].value); } } - if (this.result.photo) { - contact.photo = URL.createObjectURL(this.result.photo[0]); - } else { + if (this.result.photo && this.result.photo[0]) { + try { + contact.photo = FileManager.getUrl(this.result.photo[0]); + } catch (e) {} + } + if (!contact.photo) { contact.photo = 'img/placeholders/UserAvatar' + ((Math.abs(count) % 8) + 1) + '@2x.png'; } contact.photo = $sce.trustAsResourceUrl(contact.photo);