Fix backup for iOS

This commit is contained in:
Gustavo Maximiliano Cortez 2014-10-16 15:10:13 -03:00
commit 74174f9775
6 changed files with 44 additions and 7 deletions

View file

@ -5,6 +5,15 @@ angular.module('copayApp.controllers').controller('CopayersController',
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
$scope.hideAdv = true;
$scope.sendEmail = function(backupPlainText) {
var w = $rootScope.wallet;
var link = 'mailto:'
+ '?subject=' + escape(backupService.getFilename(w))
+ '&body=' + escape(backupPlainText) + '';
window.location.href = link;
};
$scope.skipBackup = function() {
var w = $rootScope.wallet;
w.setBackupReady(true);

View file

@ -27,6 +27,15 @@ angular.module('copayApp.controllers').controller('MoreController',
decimals: 8
}];
$scope.sendEmail = function(backupPlainText) {
var w = $rootScope.wallet;
var link = 'mailto:'
+ '?subject=' + escape(backupService.getFilename(w))
+ '&body=' + escape(backupPlainText) + '';
window.location.href = link;
};
$scope.selectedAlternative = {
name: w.settings.alternativeName,
isoCode: w.settings.alternativeIsoCode

View file

@ -17,11 +17,15 @@ BackupService.prototype.getBackup = function(wallet) {
return wallet.toEncryptedObj();
};
BackupService.prototype.download = function(wallet) {
var ew = this.getBackup(wallet);
BackupService.prototype.getFilename = function(wallet) {
var walletName = this.getName(wallet);
var copayerName = this.getCopayer(wallet);
var filename = (copayerName ? copayerName + '-' : '') + walletName + '-keybackup.json.aes';
return (copayerName ? copayerName + '-' : '') + walletName + '-keybackup.json.aes';
};
BackupService.prototype.download = function(wallet) {
var ew = this.getBackup(wallet);
var filename = this.getFilename(wallet);
this.notifications.success('Backup created', 'Encrypted backup file saved');
var blob = new Blob([ew], {