Merge pull request #5564 from cmgustavo/feat/new-pushnotifications-01

Feat/new pushnotifications 01
This commit is contained in:
Matias Alejo Garcia 2017-03-10 17:12:27 -03:00 committed by GitHub
commit 1c01a99945
14 changed files with 147 additions and 154 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService, storageService, $ionicHistory, $timeout, $ionicScrollDelegate) {
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, profileService, feeService, storageService, $ionicHistory, $timeout, $ionicScrollDelegate) {
var updateConfig = function() {
var config = configService.getSync();

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $timeout, $stateParams, $ionicConfig, profileService, configService, walletService, platformInfo) {
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $timeout, $stateParams, $ionicConfig, profileService, configService, walletService, platformInfo, pushNotificationsService) {
$scope.$on("$ionicView.beforeLeave", function() {
$ionicConfig.views.swipeBackEnabled(true);
@ -46,7 +46,7 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
walletId: walletId
});
} else {
profileService.pushNotificationsInit();
pushNotificationsService.init();
$state.go('onboarding.backupRequest', {
walletId: walletId
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, $timeout, $stateParams, $ionicConfig, profileService, configService, $interval) {
angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, $timeout, $stateParams, $ionicConfig, profileService, configService, $interval, pushNotificationsService) {
$scope.$on("$ionicView.enter", function() {
$ionicConfig.views.swipeBackEnabled(false);
@ -15,7 +15,7 @@ angular.module('copayApp.controllers').controller('notificationsController', fun
$scope.allowNotif = function() {
$scope.notificationDialogOpen = true;
$timeout(function() {
profileService.pushNotificationsInit();
pushNotificationsService.init();
});
$scope.notificationPromise = $interval(function() {
PushNotification.hasPermission(function(data) {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
function($scope, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
function($scope, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService, pushNotificationsService) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
if (!data.stateParams || !data.stateParams.walletId) {
@ -36,6 +36,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
} else {
pushNotificationsService.unsubscribe($scope.wallet);
$ionicHistory.nextViewOptions({
disableAnimate: true,
historyRoot: true

View file

@ -9,7 +9,7 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
$scope.isIOSApp = platformInfo.isIOS && platformInfo.isCordova;
$scope.pushNotifications = {
value: config.pushNotifications.enabled
value: config.pushNotificationsEnabled
};
$scope.latestEmail = {
@ -31,16 +31,14 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
$scope.pushNotificationsChange = function() {
if (!$scope.pushNotifications) return;
var opts = {
pushNotifications: {
enabled: $scope.pushNotifications.value
}
pushNotificationsEnabled: $scope.pushNotifications.value
};
configService.set(opts, function(err) {
if (opts.pushNotifications.enabled)
profileService.pushNotificationsInit();
else
pushNotificationsService.disableNotifications(profileService.getWallets());
if (err) $log.debug(err);
if (opts.pushNotificationsEnabled)
pushNotificationsService.init();
else
pushNotificationsService.disable();
});
};

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, feedbackService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService) {
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, feedbackService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService, pushNotificationsService) {
var wallet;
var listeners = [];
var notifications = [];
@ -105,8 +105,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.bitpayCardItems = cards;
});
configService.whenAvailable(function() {
var config = configService.getSync();
configService.whenAvailable(function(config) {
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
if ($scope.recentTransactionsEnabled) getNotifications();
@ -116,6 +115,8 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.nextStepsItems = nextStepsService.get();
}
pushNotificationsService.init();
$timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply();