From 6143dd4066a08473484704cf9fb0e90dd948024f Mon Sep 17 00:00:00 2001 From: Gordon Hall Date: Tue, 3 Jun 2014 10:50:37 -0400 Subject: [PATCH] add better handling of native menu actions, add handlers for backup --- js/shell.js | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/js/shell.js b/js/shell.js index de3ce38fc..c57678671 100644 --- a/js/shell.js +++ b/js/shell.js @@ -14,7 +14,9 @@ if (typeof module !== 'undefined') module = { exports: null }; // are we running in copay shell? - if (window.process && process.type === 'renderer') initCopayShellBindings(); + if (window.process && process.type === 'renderer') { + window.cshell = initCopayShellBindings(); + } function controller(name) { return angular.element( @@ -29,8 +31,11 @@ var ipc = require('ipc'); ipc.on('address:create', function(data) { - location.href = '#/addresses'; - controller('AddressesController').newAddr(); + var ctrl = controller('AddressesController'); + if (ctrl) { + location.href = '#/addresses'; + ctrl.newAddr(); + } }); ipc.on('transactions:send', function(data) { @@ -38,23 +43,39 @@ }); ipc.on('transactions:all', function(data) { - location.href = '#/transactions'; - controller('TransactionsController').show(); + var ctrl = controller('TransactionsController'); + if (ctrl) { + location.href = '#/transactions'; + ctrl.show(); + } }); ipc.on('transactions:pending', function(data) { - location.href = '#/transactions'; - controller('TransactionsController').show(true); + var ctrl = controller('TransactionsController'); + if (ctrl) { + location.href = '#/transactions'; + ctrl.show(true); + } }); ipc.on('backup:download', function(data) { - + var ctrl = controller('BackupController'); + if (ctrl) { + location.href = '#/backup'; + ctrl.download(); + } }); ipc.on('backup:email', function(data) { - + var ctrl = controller('BackupController'); + if (ctrl) { + location.href = '#/backup'; + ctrl.email(); + } }); + return ipc; + }; })();