From 04e40043d27b0ff221e651bb9cdfa7ff00048a83 Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 24 Jul 2017 16:58:20 +0200 Subject: [PATCH] Add View -> Debug Log to menu bar Just send an event from the main process to the renderer, The latter routes it the appropriate view method. For now it's a no-op unless the main window exists and it is showing the inbox, which will be addressed in a future commit. // FREEBIE --- app/menu.js | 6 ++++++ js/background.js | 3 +++ main.js | 9 +++++++++ preload.js | 3 +++ 4 files changed, 21 insertions(+) diff --git a/app/menu.js b/app/menu.js index f12ab2510..f004f21de 100644 --- a/app/menu.js +++ b/app/menu.js @@ -36,6 +36,12 @@ const template = [ { label: 'View', submenu: [ + { + label: 'Debug Log' + }, + { + type: 'separator' + }, { role: 'reload' }, diff --git a/js/background.js b/js/background.js index dfc078b82..cc1468fdc 100644 --- a/js/background.js +++ b/js/background.js @@ -78,6 +78,9 @@ appView.openInstaller(); } + Whisper.events.on('showDebugLog', function() { + appView.inboxView.showDebugLog(); + }); Whisper.events.on('unauthorized', function() { appView.inboxView.networkStatusView.update(); }); diff --git a/main.js b/main.js index 081b328ec..19e87f354 100644 --- a/main.js +++ b/main.js @@ -149,6 +149,12 @@ function createWindow () { }); } +function showDebugLog() { + if (mainWindow) { + mainWindow.webContents.send('debug-log') + } +} + // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. @@ -169,6 +175,9 @@ app.on('ready', function() { template[3].submenu[3].click = function() { mainWindow.show(); }; + template[2].submenu[0].click = showDebugLog; + } else { + template[1].submenu[0].click = showDebugLog; } const menu = Menu.buildFromTemplate(template); diff --git a/preload.js b/preload.js index 8d9fde4c1..58b88392e 100644 --- a/preload.js +++ b/preload.js @@ -24,6 +24,9 @@ console.log('restart'); ipc.send('restart'); }; + ipc.on('debug-log', function() { + Whisper.events.trigger('showDebugLog'); + }); /** * Enables spell-checking and the right-click context menu in text editors. * Electron (`webFrame.setSpellCheckProvider`) only underlines misspelled words;