diff --git a/src/browser/index.jsx b/src/browser/index.jsx index 165d51b7..3b82050a 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -63,6 +63,14 @@ var MainPage = React.createClass({ this.handleSelect(this.state.key - 1); }); + // reload the activated tab + ipcRenderer.on('reload-tab', (event) => { + this.refs[`mattermostView${this.state.key}`].reload(); + }); + ipcRenderer.on('clear-cache-and-reload-tab', (event) => { + this.refs[`mattermostView${this.state.key}`].clearCacheAndReload(); + }); + var focusListener = function() { var webview = document.getElementById('mattermostView' + thisObj.state.key); webview.focus(); @@ -185,7 +193,7 @@ var MainPage = React.createClass({ } var id = 'mattermostView' + index; return () + onNotificationClick={ handleNotificationClick } ref={ id } />) }); var views_row = ( { views } @@ -401,6 +409,16 @@ var MattermostView = React.createClass({ } }); }, + reload: function() { + var webview = ReactDOM.findDOMNode(this.refs.webview); + webview.reload(); + }, + clearCacheAndReload() { + var webContents = ReactDOM.findDOMNode(this.refs.webview).getWebContents(); + webContents.session.clearCache(() => { + webContents.reload(); + }); + }, render: function() { const errorView = this.state.errorInfo ? () : null; // 'disablewebsecurity' is necessary to display external images. diff --git a/src/main/menus/app.js b/src/main/menus/app.js index 52ed7058..e5fd6432 100644 --- a/src/main/menus/app.js +++ b/src/main/menus/app.js @@ -99,18 +99,27 @@ var createTemplate = function(mainWindow, config) { accelerator: 'CmdOrCtrl+R', click: function(item, focusedWindow) { if (focusedWindow) { - focusedWindow.reload(); + if (focusedWindow === mainWindow) { + mainWindow.webContents.send('reload-tab'); + } + else { + focusedWindow.reload(); + } } } }, { label: 'Clear Cache and Reload', accelerator: 'Shift+CmdOrCtrl+R', click: function(item, focusedWindow) { - // TODO: should reload the selected tab only if (focusedWindow) { - focusedWindow.webContents.session.clearCache(function() { - focusedWindow.reload(); - }); + if (focusedWindow === mainWindow) { + mainWindow.webContents.send('clear-cache-and-reload-tab'); + } + else { + focusedWindow.webContents.session.clearCache(function() { + focusedWindow.reload(); + }); + } } } }, {