fix merge conflicts

This commit is contained in:
Marty Alcala 2016-11-10 18:18:25 -05:00
commit 26fcb27a58
8 changed files with 136 additions and 140 deletions

View file

@ -87,6 +87,7 @@
"start": "npm run build:www && ionic serve --nolivereload --nogulp -s", "start": "npm run build:www && ionic serve --nolivereload --nogulp -s",
"start:ios": "npm run build:www && npm run build:ios && npm run open:ios", "start:ios": "npm run build:www && npm run build:ios && npm run open:ios",
"start:android": "npm run build:www && npm run build:android && npm run run:android", "start:android": "npm run build:www && npm run build:android && npm run run:android",
"start:desktop": "npm start",
"watch": "grunt watch", "watch": "grunt watch",
"build:www": "grunt", "build:www": "grunt",
"build:www-release": "grunt prod", "build:www-release": "grunt prod",

View file

@ -79,8 +79,8 @@ angular.module('copayApp.controllers').controller('copayersController',
}; };
$scope.goHome = function() { $scope.goHome = function() {
$ionicHistory.removeBackView();
$state.go('tabs.home'); $state.go('tabs.home');
$ionicHistory.clearHistory();
}; };
}); });

View file

@ -1,9 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, $log, ongoingProcess, platformInfo, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService, popupService, $state, $ionicHistory) { angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $log, ongoingProcess, platformInfo, $ionicScrollDelegate, txFormatService, bwcError, gettextCatalog, lodash, walletService, popupService, $ionicHistory) {
var self = $scope.self;
var tx = $scope.tx;
var copayers = $scope.copayers;
var isGlidera = $scope.isGlidera; var isGlidera = $scope.isGlidera;
var GLIDERA_LOCK_TIME = 6 * 60 * 60; var GLIDERA_LOCK_TIME = 6 * 60 * 60;
var now = Math.floor(Date.now() / 1000); var now = Math.floor(Date.now() / 1000);
@ -18,8 +15,8 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.color = $scope.wallet.color; $scope.color = $scope.wallet.color;
$scope.data = {}; $scope.data = {};
$scope.hasClick = platformInfo.hasClick; $scope.hasClick = platformInfo.hasClick;
$scope.displayAmount = getDisplayAmount(tx.amountStr); $scope.displayAmount = getDisplayAmount($scope.tx.amountStr);
$scope.displayUnit = getDisplayUnit(tx.amountStr); $scope.displayUnit = getDisplayUnit($scope.tx.amountStr);
initActionList(); initActionList();
checkPaypro(); checkPaypro();
} }
@ -46,12 +43,12 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.actionList.push({ $scope.actionList.push({
type: 'created', type: 'created',
time: tx.createdOn, time: $scope.tx.createdOn,
description: actionDescriptions['created'], description: actionDescriptions['created'],
by: tx.creatorName by: $scope.tx.creatorName
}); });
lodash.each(tx.actions, function(action) { lodash.each($scope.tx.actions, function(action) {
$scope.actionList.push({ $scope.actionList.push({
type: action.type, type: action.type,
time: action.createdOn, time: action.createdOn,
@ -61,103 +58,14 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
}); });
}; };
$scope.$on('accepted', function(event) {
$scope.sign();
});
// ToDo: use tx.customData instead of tx.message
if (tx.message === 'Glidera transaction' && isGlidera) {
tx.isGlidera = true;
if (tx.canBeRemoved) {
tx.canBeRemoved = (Date.now() / 1000 - (tx.ts || tx.createdOn)) > GLIDERA_LOCK_TIME;
}
}
var setSendError = function(msg) {
$scope.sendStatus = '';
var error = msg || gettextCatalog.getString('Could not send payment');
popupService.showAlert(gettextCatalog.getString('Error'), error);
}
$scope.sign = function(onSendStatusChange) {
$scope.loading = true;
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
$scope.$emit('UpdateTx');
if (err) return setSendError(err);
success();
}, onSendStatusChange);
};
function setError(err, prefix) {
$scope.loading = false;
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, prefix));
};
$scope.reject = function(txp) {
var title = gettextCatalog.getString('Warning!');
var msg = gettextCatalog.getString('Are you sure you want to reject this transaction?');
popupService.showConfirm(title, msg, null, null, function(res) {
if (res) {
$scope.loading = true;
walletService.reject($scope.wallet, $scope.tx, function(err, txpr) {
if (err)
return setError(err, gettextCatalog.getString('Could not reject payment'));
$scope.close();
});
}
});
};
$scope.remove = function() {
$scope.loading = true;
$timeout(function() {
ongoingProcess.set('removeTx', true);
walletService.removeTx($scope.wallet, $scope.tx, function(err) {
ongoingProcess.set('removeTx', false);
// Hacky: request tries to parse an empty response
if (err && !(err.message && err.message.match(/Unexpected/))) {
$scope.$emit('UpdateTx');
return setError(err, gettextCatalog.getString('Could not delete payment proposal'));
}
$scope.close();
});
}, 10);
};
$scope.broadcast = function(txp) {
$scope.loading = true;
$timeout(function() {
ongoingProcess.set('broadcastTx', true);
walletService.broadcastTx($scope.wallet, $scope.tx, function(err, txpb) {
ongoingProcess.set('broadcastTx', false);
if (err) {
return setError(err, gettextCatalog.getString('Could not broadcast payment'));
}
$scope.close();
});
}, 10);
};
$scope.getShortNetworkName = function() {
return $scope.wallet.credentials.networkName.substring(0, 4);
};
function checkPaypro() { function checkPaypro() {
if (tx.payProUrl && !platformInfo.isChromeApp) { if ($scope.tx.payProUrl && !platformInfo.isChromeApp) {
$scope.wallet.fetchPayPro({ $scope.wallet.fetchPayPro({
payProUrl: tx.payProUrl, payProUrl: $scope.tx.payProUrl,
}, function(err, paypro) { }, function(err, paypro) {
if (err) return; if (err) return;
tx.paypro = paypro; $scope.tx.paypro = paypro;
paymentTimeControl(tx.paypro.expires); paymentTimeControl($scope.tx.paypro.expires);
$timeout(function() { $timeout(function() {
$ionicScrollDelegate.resize(); $ionicScrollDelegate.resize();
}, 10); }, 10);
@ -187,32 +95,132 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
}; };
}; };
lodash.each(['TxProposalRejectedBy', 'TxProposalAcceptedBy', 'transactionProposalRemoved', 'TxProposalRemoved', 'NewOutgoingTx', 'UpdateTx'], function(eventName) { $scope.$on('accepted', function(event) {
$rootScope.$on(eventName, function() { $scope.sign();
$scope.wallet.getTx($scope.tx.id, function(err, tx) { });
if (err) {
if (err.message && err.message == 'TX_NOT_FOUND' && // ToDo: use tx.customData instead of tx.message
(eventName == 'transactionProposalRemoved' || eventName == 'TxProposalRemoved')) { if ($scope.tx.message === 'Glidera transaction' && isGlidera) {
$scope.tx.removed = true; $scope.tx.isGlidera = true;
$scope.tx.canBeRemoved = false; if ($scope.tx.canBeRemoved) {
$scope.tx.pendingForUs = false; $scope.tx.canBeRemoved = (Date.now() / 1000 - ($scope.tx.ts || $scope.tx.createdOn)) > GLIDERA_LOCK_TIME;
$scope.$apply(); }
}
var setError = function (err, prefix) {
$scope.sendStatus = '';
$scope.loading = false;
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, prefix));
};
$scope.sign = function(onSendStatusChange) {
$scope.loading = true;
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
$scope.$emit('UpdateTx');
if (err) return setError(err, gettextCatalog.getString('Could not send payment'));
success();
}, onSendStatusChange);
};
$scope.reject = function(txp) {
var title = gettextCatalog.getString('Warning!');
var msg = gettextCatalog.getString('Are you sure you want to reject this transaction?');
popupService.showConfirm(title, msg, null, null, function(res) {
if (res) {
$scope.loading = true;
walletService.reject($scope.wallet, $scope.tx, function(err, txpr) {
if (err)
return setError(err, gettextCatalog.getString('Could not reject payment'));
$scope.close();
});
}
});
};
$scope.remove = function() {
var title = gettextCatalog.getString('Warning!');
var msg = gettextCatalog.getString('Are you sure you want to remove this transaction?');
popupService.showConfirm(title, msg, null, null, function(res) {
if (res) {
ongoingProcess.set('removeTx', true);
walletService.removeTx($scope.wallet, $scope.tx, function(err) {
ongoingProcess.set('removeTx', false);
// Hacky: request tries to parse an empty response
if (err && !(err.message && err.message.match(/Unexpected/))) {
$scope.$emit('UpdateTx');
return setError(err, gettextCatalog.getString('Could not delete payment proposal'));
} }
return;
$scope.close();
});
}
});
};
$scope.broadcast = function(txp) {
$scope.loading = true;
$timeout(function() {
ongoingProcess.set('broadcastTx', true);
walletService.broadcastTx($scope.wallet, $scope.tx, function(err, txpb) {
ongoingProcess.set('broadcastTx', false);
if (err) {
return setError(err, gettextCatalog.getString('Could not broadcast payment'));
} }
var action = lodash.find(tx.actions, { $scope.close();
copayerId: $scope.wallet.credentials.copayerId
});
$scope.tx = txFormatService.processTx(tx);
if (!action && tx.status == 'pending')
$scope.tx.pendingForUs = true;
$scope.updateCopayerList();
$scope.$apply();
}); });
}, 10);
};
$scope.getShortNetworkName = function() {
return $scope.wallet.credentials.networkName.substring(0, 4);
};
var updateTxInfo = function(eventName) {
$scope.wallet.getTx($scope.tx.id, function(err, tx) {
if (err) {
if (err.message && err.message == 'Transaction proposal not found' &&
(eventName == 'transactionProposalRemoved' || eventName == 'TxProposalRemoved')) {
$scope.tx.removed = true;
$scope.tx.canBeRemoved = false;
$scope.tx.pendingForUs = false;
$scope.$apply();
}
return;
}
var action = lodash.find(tx.actions, {
copayerId: $scope.wallet.credentials.copayerId
});
$scope.tx = txFormatService.processTx(tx);
if (!action && tx.status == 'pending')
$scope.tx.pendingForUs = true;
$scope.updateCopayerList();
initActionList();
$scope.$apply();
});
};
var bwsEvent = $rootScope.$on('bwsEvent', function(e, walletId, type, n) {
lodash.each([
'TxProposalRejectedBy',
'TxProposalAcceptedBy',
'transactionProposalRemoved',
'TxProposalRemoved',
'NewOutgoingTx',
'UpdateTx'
], function(eventName) {
if (walletId == $scope.wallet.id && type == eventName) {
updateTxInfo(eventName);
}
}); });
}); });
@ -252,6 +260,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
}; };
$scope.close = function() { $scope.close = function() {
bwsEvent();
$scope.loading = null; $scope.loading = null;
$scope.txpDetailsModal.hide(); $scope.txpDetailsModal.hide();
}; };

View file

@ -1,27 +1,21 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $ionicHistory, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $ionicHistory, $scope, $stateParams, walletService, lodash, gettextCatalog, profileService, configService, externalLinkService, popupService) {
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
var wallet = profileService.getWallet($stateParams.walletId);
$scope.wallet = wallet; $scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.title = gettextCatalog.getString('Transaction'); $scope.title = gettextCatalog.getString('Transaction');
$scope.wallet = profileService.getWallet(data.stateParams.walletId);
$scope.color = $scope.wallet.color;
$scope.copayerId = $scope.wallet.credentials.copayerId;
$scope.isShared = $scope.wallet.credentials.n > 1;
$scope.init = function() { walletService.getTx($scope.wallet, $stateParams.txid, function(err, tx) {
$scope.alternativeIsoCode = walletSettings.alternativeIsoCode;
$scope.color = wallet.color;
$scope.copayerId = wallet.credentials.copayerId;
$scope.isShared = wallet.credentials.n > 1;
walletService.getTx(wallet, $stateParams.txid, function(err, tx) {
if (err) { if (err) {
$log.warn('Could not get tx'); $log.warn('Could not get tx');
$ionicHistory.goBack(); $ionicHistory.goBack();
return; return;
} }
$scope.btx = tx; $scope.btx = tx;
$scope.btx.feeLevel = walletSettings.feeLevel;
if ($scope.btx.action != 'invalid') { if ($scope.btx.action != 'invalid') {
if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds');
if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds');
@ -34,7 +28,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
updateMemo(); updateMemo();
initActionList(); initActionList();
}); });
}; });
function getDisplayAmount(amountStr) { function getDisplayAmount(amountStr) {
return amountStr.split(' ')[0]; return amountStr.split(' ')[0];
@ -45,7 +39,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
} }
function updateMemo() { function updateMemo() {
walletService.getTxNote(wallet, $scope.btx.txid, function(err, note) { walletService.getTxNote($scope.wallet, $scope.btx.txid, function(err, note) {
if (err) { if (err) {
$log.warn('Could not fetch transaction note: ' + err); $log.warn('Could not fetch transaction note: ' + err);
return; return;
@ -53,18 +47,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
if (!note) return; if (!note) return;
$scope.btx.note = note; $scope.btx.note = note;
$scope.$apply();
walletService.getTx(wallet, $scope.btx.txid, function(err, tx) {
if (err) {
$log.error(err);
return;
}
tx.note = note;
$timeout(function() {
$scope.$apply();
});
});
}); });
} }
@ -109,9 +92,12 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
} }
if ($scope.btx.note && $scope.btx.note.body) opts.defaultText = $scope.btx.note.body; if ($scope.btx.note && $scope.btx.note.body) opts.defaultText = $scope.btx.note.body;
popupService.showPrompt(wallet.name, gettextCatalog.getString('Memo'), opts, function(text) { popupService.showPrompt($scope.wallet.name, gettextCatalog.getString('Memo'), opts, function(text) {
if (typeof text == "undefined") return; if (typeof text == "undefined") return;
$scope.btx.note = {
body: text
};
$log.debug('Saving memo'); $log.debug('Saving memo');
var args = { var args = {
@ -119,17 +105,10 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
body: text body: text
}; };
walletService.editTxNote(wallet, args, function(err, res) { walletService.editTxNote($scope.wallet, args, function(err, res) {
if (err) { if (err) {
$log.debug('Could not save tx comment ' + err); $log.debug('Could not save tx comment ' + err);
return;
} }
// This is only to refresh the current screen data
updateMemo();
$scope.btx.searcheableString = null;
$timeout(function() {
$scope.$apply();
});
}); });
}); });
}; };
@ -147,7 +126,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
}; };
$scope.getShortNetworkName = function() { $scope.getShortNetworkName = function() {
var n = wallet.credentials.network; var n = $scope.wallet.credentials.network;
return n.substring(0, 4); return n.substring(0, 4);
}; };
@ -155,5 +134,4 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.txDetailsModal.hide(); $scope.txDetailsModal.hide();
}; };
$scope.init();
}); });

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, profileService, lodash, configService, gettextCatalog, platformInfo, walletService, txpModalService, externalLinkService, popupService, addressbookService, storageService, $ionicHistory, $ionicScrollDelegate, $window) { angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicHistory, profileService, lodash, configService, gettextCatalog, platformInfo, walletService, txpModalService, externalLinkService, popupService, addressbookService, storageService, $ionicScrollDelegate, $window) {
var HISTORY_SHOW_LIMIT = 10; var HISTORY_SHOW_LIMIT = 10;
var currentTxHistoryPage = 0; var currentTxHistoryPage = 0;
@ -87,6 +87,14 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
$scope.close = function() { $scope.close = function() {
$scope.searchModal.hide(); $scope.searchModal.hide();
}; };
$scope.openTx = function(tx) {
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$scope.searchModal.hide();
$scope.openTxModal(tx);
};
}; };
$scope.openTxModal = function(btx) { $scope.openTxModal = function(btx) {

View file

@ -182,7 +182,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
views: { views: {
'tab-home@tabs': { 'tab-home@tabs': {
controller: 'txDetailsController', controller: 'txDetailsController',
templateUrl: 'views/modals/tx-details.html' templateUrl: 'views/tx-details.html'
} }
} }
}) })

View file

@ -18,7 +18,7 @@
</div> </div>
<div class="list"> <div class="list">
<div class="item" ng-repeat="btx in txHistorySearchResults track by btx.txid" ng-click="openTxModal(btx)"> <div class="item" ng-repeat="btx in txHistorySearchResults track by btx.txid" ng-click="openTx(btx)">
<span class="item-note text-right"> <span class="item-note text-right">
<span class="size-16" ng-class="{'text-bold': btx.recent}"> <span class="size-16" ng-class="{'text-bold': btx.recent}">

View file

@ -53,7 +53,7 @@
{{btx.creatorName}} <time>{{ (btx.ts || btx.createdOn ) * 1000 | amDateFormat:'MM/DD/YYYY hh:mm a'}}</time> {{btx.creatorName}} <time>{{ (btx.ts || btx.createdOn ) * 1000 | amDateFormat:'MM/DD/YYYY hh:mm a'}}</time>
</span> </span>
</div> </div>
<a class="item item-icon-right" ng-class="{'single-line': !btx.note.body && !btx.message}" ng-hide="insuffientFunds" ng-click="showCommentPopup()"> <a class="item item-icon-right" ng-class="{'single-line': !btx.note.body && !btx.message}" ng-click="showCommentPopup()">
<span class="label" translate>Memo</span> <span class="label" translate>Memo</span>
<div class="item-note" style="display: block; float: none; margin-bottom: .25rem;"> <div class="item-note" style="display: block; float: none; margin-bottom: .25rem;">
{{btx.note.body || btx.message}} {{btx.note.body || btx.message}}