feed
This commit is contained in:
parent
d7080bb2c9
commit
7229adf08a
8 changed files with 335 additions and 64 deletions
47
src/js/controllers/activity.js
Normal file
47
src/js/controllers/activity.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('activityController',
|
||||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
|
||||
var self = this;
|
||||
|
||||
var setNotifications = function(notifications) {
|
||||
var n = walletService.processNotifications(notifications);
|
||||
|
||||
$scope.notifications = n;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
|
||||
var i = $scope.wallets.length,
|
||||
j = 0;
|
||||
// var timeSpan = 60 * 60 * 24 * 7; TODO
|
||||
var timeSpan = 60 * 60 * 6;
|
||||
var notifications = [];
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
|
||||
walletService.getNotifications(wallet, {
|
||||
timeSpan: timeSpan
|
||||
}, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
notifications.push(n);
|
||||
if (++j == i) {
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(lodash.compact(lodash.flatten(notifications)));
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -4,27 +4,58 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
|
||||
var self = this;
|
||||
|
||||
self.setWallets = function() {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
var setNotifications = function(notifications) {
|
||||
|
||||
var n = walletService.processNotifications(notifications, 5);
|
||||
|
||||
$scope.notifications = n;
|
||||
$scope.notificationsMore = notifications.length > 5 ? notifications.length - 5 : null;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
self.updateAllWallets = function() {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
|
||||
var i = $scope.wallets.length;
|
||||
var i = $scope.wallets.length, j =0;
|
||||
// var timeSpan = 60 * 60 * 24 * 7;
|
||||
var timeSpan = 60 * 60 * 24 * 1;
|
||||
var notifications = [];
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
}
|
||||
wallet.status = status;
|
||||
});
|
||||
|
||||
walletService.getNotifications(wallet, {
|
||||
timeSpan: timeSpan
|
||||
}, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
notifications.push(n);
|
||||
if (++j == i) {
|
||||
$scope.fetchingNotifications = false;
|
||||
setNotifications(lodash.compact(lodash.flatten(notifications)));
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
self.updateWallet = function(wallet) {
|
||||
|
||||
$log.debug('Updating wallet:' + wallet.name)
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
|
|
@ -32,7 +63,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
return;
|
||||
}
|
||||
wallet.status = status;
|
||||
$timeout(function(){
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
|
|
@ -55,7 +86,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
];
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
lodash.each(listeners, function(x){
|
||||
lodash.each(listeners, function(x) {
|
||||
x();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, storageService) {
|
||||
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, storageService, $ionicPopup) {
|
||||
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isWP = platformInfo.isWP;
|
||||
|
|
@ -39,10 +39,10 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
setPendingTxps(status.pendingTxps);
|
||||
|
||||
$scope.status = status;
|
||||
$timeout(function(){
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
];
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
lodash.each(listeners, function(x){
|
||||
lodash.each(listeners, function(x) {
|
||||
x();
|
||||
});
|
||||
});
|
||||
|
|
@ -117,7 +117,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
walletService.recreate();
|
||||
};
|
||||
|
||||
$scope.updateTxHistory = function() {
|
||||
$scope.updateTxHistory = function(cb) {
|
||||
|
||||
if ($scope.updatingTxHistory) return;
|
||||
|
||||
|
|
@ -129,10 +129,10 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.updatingTxHistoryProgress = txs ? txs.length : 0;
|
||||
$scope.completeTxHistory = txs;
|
||||
$scope.showHistory();
|
||||
$timeout(function(){
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
|
||||
|
||||
};
|
||||
|
||||
$timeout(function() {
|
||||
|
|
@ -148,9 +148,11 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.completeTxHistory = txHistory;
|
||||
|
||||
$scope.showHistory();
|
||||
$timeout(function(){
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
@ -168,9 +170,9 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
};
|
||||
|
||||
$scope.updateAll = function() {
|
||||
$scope.updateAll = function(cb) {
|
||||
$scope.updateStatus(false);
|
||||
$scope.updateTxHistory();
|
||||
$scope.updateTxHistory(cb);
|
||||
}
|
||||
|
||||
var hideBalance = function() {
|
||||
|
|
@ -200,7 +202,30 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
hideBalance();
|
||||
$ionicNavBarDelegate.title(wallet.name);
|
||||
|
||||
$scope.updateAll();
|
||||
};
|
||||
|
||||
$scope.updateAll(function() {
|
||||
if ($stateParams.txid) {
|
||||
var txp = lodash.find($scope.completeTxHistory, {
|
||||
txid: $stateParams.txid
|
||||
});
|
||||
if (txp) {
|
||||
$scope.openTxModal(tx);
|
||||
} else {
|
||||
$ionicPopup.alert({
|
||||
title: gettext('TX not available'),
|
||||
});
|
||||
}
|
||||
} else if ($stateParams.txpId) {
|
||||
var txp = lodash.find($scope.txps, {
|
||||
id: $stateParams.txpId
|
||||
});
|
||||
if (txp) {
|
||||
$scope.openTxpModal(txp);
|
||||
} else {
|
||||
$ionicPopup.alert({
|
||||
title: gettext('Proposal not longer available'),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue