refactor
This commit is contained in:
parent
9ce67ed68a
commit
ceb97796c7
2 changed files with 33 additions and 9 deletions
|
|
@ -21,12 +21,29 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
||||||
if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds');
|
if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateMemo();
|
||||||
initActionList();
|
initActionList();
|
||||||
getAlternativeAmount();
|
getAlternativeAmount();
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 100);
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function updateMemo() {
|
||||||
|
wallet.getTxNote({
|
||||||
|
txid: $scope.btx.txid
|
||||||
|
}, function(err, note) {
|
||||||
|
if (err || !note) {
|
||||||
|
$log.debug(gettextCatalog.getString('Could not fetch transaction note'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.note = note;
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function initActionList() {
|
function initActionList() {
|
||||||
|
|
@ -64,12 +81,12 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.showCommentPopup = function() {
|
$scope.showCommentPopup = function() {
|
||||||
popupService.showPrompt(gettextCatalog.getString('Memo'), ' ', {}, function(res) {
|
popupService.showPrompt(gettextCatalog.getString('Memo'), ' ', {}, function(text) {
|
||||||
$log.debug('Saving memo');
|
$log.debug('Saving memo');
|
||||||
|
|
||||||
var args = {
|
var args = {
|
||||||
txid: $scope.btx.txid,
|
txid: $scope.btx.txid,
|
||||||
body: res
|
body: text
|
||||||
};
|
};
|
||||||
|
|
||||||
wallet.editTxNote(args, function(err) {
|
wallet.editTxNote(args, function(err) {
|
||||||
|
|
@ -81,7 +98,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
||||||
$scope.btx.note = null;
|
$scope.btx.note = null;
|
||||||
if (args.body) {
|
if (args.body) {
|
||||||
$scope.btx.note = {};
|
$scope.btx.note = {};
|
||||||
$scope.btx.note.body = res;
|
$scope.btx.note.body = text;
|
||||||
$scope.btx.note.editedByName = wallet.credentials.copayerName;
|
$scope.btx.note.editedByName = wallet.credentials.copayerName;
|
||||||
$scope.btx.note.editedOn = Math.floor(Date.now() / 1000);
|
$scope.btx.note.editedOn = Math.floor(Date.now() / 1000);
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +106,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 200);
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -503,23 +503,30 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getTx = function(wallet, txid, cb) {
|
root.getTx = function(wallet, txid, cb) {
|
||||||
|
var tx;
|
||||||
|
|
||||||
if (wallet.completeHistory && wallet.completeHistory.isValid) {
|
if (wallet.completeHistory && wallet.completeHistory.isValid) {
|
||||||
var tx = lodash.find(wallet.completeHistory, {
|
tx = lodash.find(wallet.completeHistory, {
|
||||||
txid: txid
|
txid: txid
|
||||||
});
|
});
|
||||||
|
|
||||||
return cb(null, tx);
|
finish();
|
||||||
} else {
|
} else {
|
||||||
root.getTxHistory(wallet, {}, function(err, txHistory) {
|
root.getTxHistory(wallet, {}, function(err, txHistory) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
var tx = lodash.find(txHistory, {
|
tx = lodash.find(txHistory, {
|
||||||
txid: txid
|
txid: txid
|
||||||
});
|
});
|
||||||
|
|
||||||
return cb(null, tx);
|
finish();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function finish() {
|
||||||
|
if (tx) return cb(null, tx);
|
||||||
|
else return cb();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getTxHistory = function(wallet, opts, cb) {
|
root.getTxHistory = function(wallet, opts, cb) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue