diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js
index 3ac283d9a..0d7f7de1f 100644
--- a/src/js/controllers/create.js
+++ b/src/js/controllers/create.js
@@ -170,6 +170,7 @@ angular.module('copayApp.controllers').controller('createController',
});
return;
}
+ go.walletHome();
});
}, 100);
diff --git a/src/js/controllers/disclaimer.js b/src/js/controllers/disclaimer.js
index cb90b8603..b76567a32 100644
--- a/src/js/controllers/disclaimer.js
+++ b/src/js/controllers/disclaimer.js
@@ -44,4 +44,11 @@ angular.module('copayApp.controllers').controller('disclaimerController',
});
});
};
- });
+
+ this.accept = function() {
+ profileService.setDisclaimerAccepted(function(err) {
+ if (err) $log.error(err);
+ else go.walletHome();
+ });
+ };
+});
diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js
index 50ea3b01b..23e349a17 100644
--- a/src/js/controllers/import.js
+++ b/src/js/controllers/import.js
@@ -75,6 +75,7 @@ angular.module('copayApp.controllers').controller('importController',
} else {
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
+ go.walletHome();
}
});
}, 100);
@@ -309,6 +310,7 @@ angular.module('copayApp.controllers').controller('importController',
}
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
+ go.walletHome();
});
}, 100);
};
diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js
index f3d603535..49415116d 100644
--- a/src/js/controllers/index.js
+++ b/src/js/controllers/index.js
@@ -161,27 +161,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url);
};
- self.acceptDisclaimer = function() {
- var profile = profileService.profile;
- if (profile) profile.disclaimerAccepted = true;
- self.disclaimerAccepted = true;
- profileService.setDisclaimerAccepted(function(err) {
- if (err) $log.error(err);
- go.walletHome();
- });
- };
-
- self.isDisclaimerAccepted = function() {
- if (self.disclaimerAccepted == true) {
- go.walletHome();
- return;
- }
- profileService.isDisclaimerAccepted(function(v) {
- if (v) {
- self.acceptDisclaimer();
- } else go.path('disclaimer');
- });
- };
self.setTab = function(tab, reset, tries, switchState) {
tries = tries || 0;
@@ -1068,8 +1047,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
};
self.openMenu = function() {
- if (!self.disclaimerAccepted) return;
- go.swipe(true);
+ profileService.isDisclaimerAccepted(function(val){
+ if (val) go.swipe(true);
+ else
+ $log.debug('Disclaimer not accepted, cannot open menu');
+ });
};
self.closeMenu = function() {
@@ -1334,7 +1316,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on('Local/Resume', function(event) {
$log.debug('### Resume event');
- self.isDisclaimerAccepted();
+ profileService.isDisclaimerAccepted(function(v) {
+ if (!v) {
+ $log.debug('Disclaimer not accepted, resume to home');
+ go.path('disclaimer');
+ }
+ });
self.debouncedUpdate();
});
@@ -1476,7 +1463,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setUxLanguage();
self.setFocusedWallet();
self.debounceUpdateHistory();
- self.isDisclaimerAccepted();
storageService.getCleanAndScanAddresses(function(err, walletId) {
if (walletId && profileService.walletClients[walletId]) {
$log.debug('Clear last address cache and Scan ', walletId);
diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js
index a0647c687..4b5263ba1 100644
--- a/src/js/controllers/join.js
+++ b/src/js/controllers/join.js
@@ -128,7 +128,7 @@ angular.module('copayApp.controllers').controller('joinController',
$rootScope.$apply();
return;
}
-
+ go.walletHome();
});
}, 100);
};
diff --git a/src/js/controllers/sidebar.js b/src/js/controllers/sidebar.js
index 7cf3d57a9..b9efcd88c 100644
--- a/src/js/controllers/sidebar.js
+++ b/src/js/controllers/sidebar.js
@@ -21,6 +21,10 @@ angular.module('copayApp.controllers').controller('sidebarController',
});
+ self.closeMenu = function() {
+ go.swipe();
+ };
+
self.signout = function() {
profileService.signout();
};
@@ -60,5 +64,4 @@ angular.module('copayApp.controllers').controller('sidebarController',
};
self.setWallets();
-
});
diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js
index 178964461..4c9033503 100644
--- a/src/js/services/profileService.js
+++ b/src/js/services/profileService.js
@@ -134,7 +134,9 @@ angular.module('copayApp.services')
root._setFocus(focusedWalletId, function() {
$rootScope.$emit('Local/ProfileBound');
storageService.getDeviceToken(function(err, token) {
- if (!token) pushNotificationsService.pushNotificationsInit();
+ if (!token)
+ pushNotificationsService.pushNotificationsInit();
+
root.isDisclaimerAccepted(function(val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
@@ -413,6 +415,7 @@ angular.module('copayApp.services')
handleImport(function() {
root.setAndStoreFocus(walletId, function() {
storageService.storeProfile(root.profile, function(err) {
+
$rootScope.$emit('Local/ProfileCreated');
if (config.pushNotifications.enabled)
pushNotificationsService.enableNotifications(root.walletClients);
@@ -447,7 +450,7 @@ angular.module('copayApp.services')
root._addWalletClient(walletClient, opts, function(err, walletId) {
if (err) return cb(err);
root.setMetaData(walletClient, addressBook, historyCache, function(error) {
- if (error) console.log(error);
+ if (error) $log.warn(error);
return cb(err, walletId);
});
});
@@ -540,30 +543,23 @@ angular.module('copayApp.services')
};
root.setDisclaimerAccepted = function(cb) {
- storageService.getProfile(function(err, profile) {
- profile.disclaimerAccepted = true;
- storageService.storeProfile(profile, function(err) {
- return cb(err);
- });
+ root.profile.disclaimerAccepted = true;
+ storageService.storeProfile(root.profile, function(err) {
+ return cb(err);
});
};
root.isDisclaimerAccepted = function(cb) {
- storageService.getProfile(function(err, profile) {
- if (profile && profile.disclaimerAccepted)
+ var disclaimerAccepted = root.profile && root.profile.disclaimerAccepted;
+
+ if (disclaimerAccepted)
+ return cb(true);
+
+ // OLD flag
+ storageService.getCopayDisclaimerFlag(function(err, val) {
+ if (val) {
+ root.profile.disclaimerAccepted = true;
return cb(true);
- else if (profile && !profile.disclaimerAccepted) {
- storageService.getCopayDisclaimerFlag(function(err, val) {
- if (val) {
- profile.disclaimerAccepted = true;
- storageService.storeProfile(profile, function(err) {
- if (err) $log.error(err);
- return cb(true);
- });
- } else {
- return cb();
- }
- });
} else {
return cb();
}
diff --git a/src/js/services/pushNotificationsService.js b/src/js/services/pushNotificationsService.js
index ac9a3eace..ee4b72027 100644
--- a/src/js/services/pushNotificationsService.js
+++ b/src/js/services/pushNotificationsService.js
@@ -28,12 +28,19 @@ angular.module('copayApp.services')
if (!config.pushNotifications.enabled) return;
storageService.getDeviceToken(function(err, token) {
+
+ if (err || !token) {
+ $log.warn('No token available for this device. Cannot set push notifications');
+ return;
+ }
+
+
lodash.forEach(walletsClients, function(walletClient) {
var opts = {};
opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null;
opts.token = token;
root.subscribe(opts, walletClient, function(err, response) {
- if (err) $log.warn('Subscription error: ' + err.message);
+ if (err) $log.warn('Subscription error: ' + err.message + ': ' + JSON.stringify(opts));
else $log.debug('Subscribed to push notifications service: ' + JSON.stringify(response));
});
});