From 8b558c0ca2625b90ba9af971d8751f79ced6ee17 Mon Sep 17 00:00:00 2001
From: Piotr Dabrowski
Date: Fri, 2 Aug 2013 13:09:45 +0200
Subject: [PATCH] [ContactsExchanger] updated ContactsExchanger sources
Change-Id: Ib7398908174dc3b6338c68a957b5f4551fd30ace
---
js/app.js | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/js/app.js b/js/app.js
index b5965cd..0d399b6 100644
--- a/js/app.js
+++ b/js/app.js
@@ -68,9 +68,28 @@ var app = null;
*/
getAddressBooksSuccess: function getAddressBooksSuccess(addressbooks) {
if (addressbooks.length > 0) {
- var self = this;
+ var self = this,
+ resetLocalSorage = function () {
+ // Reset localStorage
+ localStorage.clear();
+ self.started = false;
+
+ // Load start page with temporary content
+ self.ui.moveToStartPage();
+ self.ui.loadTemporaryContent();
+ };
this.addressBook = addressbooks[0];
+ if (localStorage.id) {
+ try {
+ this.addressBook.get(localStorage.id);
+ } catch (err) {
+ if (err.name === "NotFoundError") {
+ resetLocalSorage();
+ }
+ }
+ }
+
// Registers to be notified when the address book changes
this.addressBook.addChangeListener({
oncontactsadded: function(contacts) {
@@ -80,15 +99,7 @@ var app = null;
oncontactsremoved: function(ids) {
// Refresh localStorage if default contact was deleted
if (ids.indexOf(localStorage.id) >= 0) {
-
- // Reset localStorage
- localStorage.clear();
- self.started = false;
-
- // Load start page with temporary content
- self.ui.moveToStartPage();
- self.ui.loadTemporaryContent();
-
+ resetLocalSorage();
alert("Your default contact has been removed. Please choose another one.");
} else {
// Refresh if choose page active
--
2.7.4