commit
5bfe1a255e
3 changed files with 45 additions and 14 deletions
|
|
@ -79,16 +79,19 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
$log.debug('Cleaning Index Instance');
|
$log.debug('Cleaning Index Instance');
|
||||||
lodash.each(self, function(v, k) {
|
lodash.each(self, function(v, k) {
|
||||||
if (lodash.isFunction(v)) return;
|
if (lodash.isFunction(v)) return;
|
||||||
if (vanillaScope[k]) return;
|
|
||||||
|
|
||||||
// This are to prevent flicker in mobile:
|
// This are to prevent flicker in mobile:
|
||||||
if (k == 'hasProfile') return;
|
if (k == 'hasProfile') return;
|
||||||
|
if (k == 'tab') return;
|
||||||
if (k == 'noFocusedWallet') return;
|
if (k == 'noFocusedWallet') return;
|
||||||
if (k == 'backgroundColor') return;
|
if (k == 'backgroundColor') return;
|
||||||
if (k == 'loadingWallet') {
|
if (k == 'loadingWallet') {
|
||||||
self.loadingWallet = true;
|
self.loadingWallet = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (vanillaScope[k]) {
|
||||||
|
self[k] = vanillaScope[k];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
delete self[k];
|
delete self[k];
|
||||||
});
|
});
|
||||||
|
|
@ -273,6 +276,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
tries = tries || 0;
|
tries = tries || 0;
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
|
var walletId = profileService.focusedClient.credentials.walletId
|
||||||
|
|
||||||
if (opts.untilItChanges && lodash.isUndefined(initStatusHash)) {
|
if (opts.untilItChanges && lodash.isUndefined(initStatusHash)) {
|
||||||
initStatusHash = _walletStatusHash();
|
initStatusHash = _walletStatusHash();
|
||||||
$log.debug('Updating status until it changes. initStatusHash:' + initStatusHash)
|
$log.debug('Updating status until it changes. initStatusHash:' + initStatusHash)
|
||||||
|
|
@ -299,6 +304,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
if (!fc) return;
|
if (!fc) return;
|
||||||
|
|
||||||
|
|
||||||
|
// If not untilItChanges...trigger history update now
|
||||||
|
if (opts.triggerTxUpdate && !opts.untilItChanges) {
|
||||||
|
$timeout(function() {
|
||||||
|
self.debounceUpdateHistory();
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
|
||||||
if (!opts.quiet)
|
if (!opts.quiet)
|
||||||
|
|
@ -308,7 +321,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
get(function(err, walletStatus) {
|
get(function(err, walletStatus) {
|
||||||
var currentStatusHash = _walletStatusHash(walletStatus);
|
var currentStatusHash = _walletStatusHash(walletStatus);
|
||||||
$log.debug('Status update. hash:' + currentStatusHash + ' Try:' + tries);
|
$log.debug('Status update. hash:' + currentStatusHash + ' Try:' + tries);
|
||||||
if (!err && opts.untilItChanges && initStatusHash == currentStatusHash && tries < 7) {
|
if (!err && opts.untilItChanges && initStatusHash == currentStatusHash && tries < 7 && walletId == profileService.focusedClient.credentials.walletId) {
|
||||||
return $timeout(function() {
|
return $timeout(function() {
|
||||||
$log.debug('Retrying update... Try:' + tries)
|
$log.debug('Retrying update... Try:' + tries)
|
||||||
return self.updateAll({
|
return self.updateAll({
|
||||||
|
|
@ -318,9 +331,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
}, initStatusHash, ++tries);
|
}, initStatusHash, ++tries);
|
||||||
}, 1400 * tries);
|
}, 1400 * tries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (walletId != profileService.focusedClient.credentials.walletId)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!opts.quiet)
|
if (!opts.quiet)
|
||||||
self.setOngoingProcess('updatingStatus', false);
|
self.setOngoingProcess('updatingStatus', false);
|
||||||
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
self.handleError(err);
|
self.handleError(err);
|
||||||
return;
|
return;
|
||||||
|
|
@ -344,7 +362,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
$rootScope.$emit('Local/BalanceUpdated', walletStatus.balance);
|
$rootScope.$emit('Local/BalanceUpdated', walletStatus.balance);
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
|
||||||
if (opts.triggerTxUpdate) {
|
if (opts.triggerTxUpdate && opts.untilItChanges) {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
self.debounceUpdateHistory();
|
self.debounceUpdateHistory();
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
@ -820,12 +838,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
var confirmedTxs = self.removeSoftConfirmedTx(txsFromLocal);
|
var confirmedTxs = self.removeSoftConfirmedTx(txsFromLocal);
|
||||||
var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null;
|
var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null;
|
||||||
|
|
||||||
|
|
||||||
// First update
|
// First update
|
||||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
if (walletId == profileService.focusedClient.credentials.walletId) {
|
||||||
self.completeHistory = txsFromLocal;
|
self.completeHistory = txsFromLocal;
|
||||||
self.setCompactTxHistory();
|
self.setCompactTxHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (historyUpdateInProgress[walletId])
|
||||||
|
return;
|
||||||
|
|
||||||
|
historyUpdateInProgress[walletId] = true;
|
||||||
|
|
||||||
function getNewTxs(newTxs, skip, i_cb) {
|
function getNewTxs(newTxs, skip, i_cb) {
|
||||||
self.getTxsFromServer(client, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
|
self.getTxsFromServer(client, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
|
||||||
|
|
@ -918,14 +941,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
if (!fc) return;
|
if (!fc) return;
|
||||||
var walletId = fc.credentials.walletId;
|
var walletId = fc.credentials.walletId;
|
||||||
|
|
||||||
if (!fc.isComplete() || historyUpdateInProgress[walletId]) {
|
if (!fc.isComplete()) {
|
||||||
self.updatingTxHistory = historyUpdateInProgress[walletId];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log.debug('Updating Transaction History');
|
$log.debug('Updating Transaction History');
|
||||||
self.txHistoryError = false;
|
self.txHistoryError = false;
|
||||||
historyUpdateInProgress[walletId] = self.updatingTxHistory = true;
|
self.updatingTxHistory = true;
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
self.updateLocalTxHistory(fc, function(err) {
|
self.updateLocalTxHistory(fc, function(err) {
|
||||||
|
|
@ -956,7 +978,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
|
|
||||||
self.throttledUpdateHistory = lodash.throttle(function() {
|
self.throttledUpdateHistory = lodash.throttle(function() {
|
||||||
self.updateHistory();
|
self.updateHistory();
|
||||||
}, 10000);
|
}, 5000);
|
||||||
|
|
||||||
self.showErrorPopup = function(msg, cb) {
|
self.showErrorPopup = function(msg, cb) {
|
||||||
$log.warn('Showing err popup:' + msg);
|
$log.warn('Showing err popup:' + msg);
|
||||||
|
|
@ -991,9 +1013,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
};
|
};
|
||||||
|
|
||||||
self.openMenu = function() {
|
self.openMenu = function() {
|
||||||
profileService.isDisclaimerAccepted(function(val){
|
profileService.isDisclaimerAccepted(function(val) {
|
||||||
if (val) go.swipe(true);
|
if (val) go.swipe(true);
|
||||||
else
|
else
|
||||||
$log.debug('Disclaimer not accepted, cannot open menu');
|
$log.debug('Disclaimer not accepted, cannot open menu');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -1245,7 +1267,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
quiet: true
|
quiet: true
|
||||||
});
|
});
|
||||||
self.debounceUpdateHistory();
|
self.debounceUpdateHistory();
|
||||||
}, 4000, {
|
}, 2000, {
|
||||||
leading: false,
|
leading: false,
|
||||||
trailing: true
|
trailing: true
|
||||||
});
|
});
|
||||||
|
|
@ -1398,7 +1420,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
$rootScope.$on('Local/NewFocusedWallet', function() {
|
$rootScope.$on('Local/NewFocusedWallet', function() {
|
||||||
self.setUxLanguage();
|
self.setUxLanguage();
|
||||||
self.setFocusedWallet();
|
self.setFocusedWallet();
|
||||||
self.debounceUpdateHistory();
|
self.updateHistory();
|
||||||
storageService.getCleanAndScanAddresses(function(err, walletId) {
|
storageService.getCleanAndScanAddresses(function(err, walletId) {
|
||||||
if (walletId && profileService.walletClients[walletId]) {
|
if (walletId && profileService.walletClients[walletId]) {
|
||||||
$log.debug('Clear last address cache and Scan ', walletId);
|
$log.debug('Clear last address cache and Scan ', walletId);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
|
||||||
notification.success(gettextCatalog.getString('Success'), gettextCatalog.getString('The wallet "{{walletName}}" was deleted', {
|
notification.success(gettextCatalog.getString('Success'), gettextCatalog.getString('The wallet "{{walletName}}" was deleted', {
|
||||||
walletName: walletName
|
walletName: walletName
|
||||||
}));
|
}));
|
||||||
|
go.walletHome();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,19 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
|
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
|
||||||
self.addr = null;
|
self.addr = null;
|
||||||
self.resetForm();
|
self.resetForm();
|
||||||
|
if (profileService.focusedClient) {
|
||||||
|
self.setAddress();
|
||||||
|
self.setSendFormInputs();
|
||||||
|
}
|
||||||
|
|
||||||
$log.debug('Cleaning WalletHome Instance');
|
$log.debug('Cleaning WalletHome Instance');
|
||||||
lodash.each(self, function(v, k) {
|
lodash.each(self, function(v, k) {
|
||||||
if (lodash.isFunction(v)) return;
|
if (lodash.isFunction(v)) return;
|
||||||
if (vanillaScope[k]) return;
|
if (vanillaScope[k]) {
|
||||||
|
self[k] = vanillaScope[k];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (k == 'isRateAvailable') return;
|
||||||
|
|
||||||
delete self[k];
|
delete self[k];
|
||||||
});
|
});
|
||||||
|
|
@ -823,7 +831,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}, 1);
|
}, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// subscription
|
||||||
this.setOngoingProcess = function(name) {
|
this.setOngoingProcess = function(name) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.blockUx = !!name;
|
self.blockUx = !!name;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue