From 2818ff6d60f3e2cebe6b2b510d1010387bfc12f7 Mon Sep 17 00:00:00 2001 From: Gordon Hall Date: Tue, 3 Jun 2014 11:55:48 -0400 Subject: [PATCH] now sending alert message to shell when menu action can't be handled --- js/shell.js | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/js/shell.js b/js/shell.js index c57678671..4067eadf7 100644 --- a/js/shell.js +++ b/js/shell.js @@ -26,52 +26,53 @@ ).scope(); }; + function needsWalletLogin(ipc) { + ipc.send('alert', 'info', 'Please select a wallet.'); + }; + function initCopayShellBindings() { var ipc = require('ipc'); ipc.on('address:create', function(data) { var ctrl = controller('AddressesController'); - if (ctrl) { - location.href = '#/addresses'; - ctrl.newAddr(); - } + if (!ctrl) return needsWalletLogin(ipc); + location.href = '#/addresses'; + ctrl.newAddr(); }); ipc.on('transactions:send', function(data) { + var ctrl = controller('SendController'); + if (!ctrl) return needsWalletLogin(ipc); location.href = '#/send'; }); ipc.on('transactions:all', function(data) { var ctrl = controller('TransactionsController'); - if (ctrl) { - location.href = '#/transactions'; - ctrl.show(); - } + if (!ctrl) return needsWalletLogin(ipc); + location.href = '#/transactions'; + ctrl.show(); }); ipc.on('transactions:pending', function(data) { var ctrl = controller('TransactionsController'); - if (ctrl) { - location.href = '#/transactions'; - ctrl.show(true); - } + if (!ctrl) return needsWalletLogin(ipc); + location.href = '#/transactions'; + ctrl.show(true); }); ipc.on('backup:download', function(data) { var ctrl = controller('BackupController'); - if (ctrl) { - location.href = '#/backup'; - ctrl.download(); - } + if (!ctrl) return needsWalletLogin(ipc); + location.href = '#/backup'; + ctrl.download(); }); ipc.on('backup:email', function(data) { var ctrl = controller('BackupController'); - if (ctrl) { - location.href = '#/backup'; - ctrl.email(); - } + if (!ctrl) return needsWalletLogin(ipc); + location.href = '#/backup'; + ctrl.email(); }); return ipc;