Added try catch for FFOS contacts manager

Trying to fix #381
This commit is contained in:
Igor Zhukov 2014-07-14 13:20:56 +04:00
parent c8eec9b54d
commit ec3dddf50d

View File

@ -331,7 +331,12 @@ angular.module('myApp.services', [])
} }
function isAvailable () { function isAvailable () {
return window.navigator && window.navigator.mozContacts && window.navigator.mozContacts.getAll; try {
return navigator.mozContacts && navigator.mozContacts.getAll;
} catch (e) {
console.error(dT(), 'phonebook n/a', e);
return false;
}
} }
function openPhonebookImport () { function openPhonebookImport () {
@ -347,9 +352,14 @@ angular.module('myApp.services', [])
return phonebookContactsPromise; return phonebookContactsPromise;
} }
try {
var request = window.navigator.mozContacts.getAll({});
} catch (e) {
return $q.reject(e);
}
var deferred = $q.defer(), var deferred = $q.defer(),
contacts = [], contacts = [],
request = window.navigator.mozContacts.getAll({}),
count = 0; count = 0;
request.onsuccess = function () { request.onsuccess = function () {