diff --git a/app/browser/reducers/autoplayReducer.js b/app/browser/reducers/autoplayReducer.js index 4e326e1526b..0cdfd8092af 100644 --- a/app/browser/reducers/autoplayReducer.js +++ b/app/browser/reducers/autoplayReducer.js @@ -15,7 +15,12 @@ const locale = require('../../locale') const messages = require('../../../js/constants/messages') const urlParse = require('../../common/urlParse') -const showAutoplayMessageBox = (location, tabId) => { +const showAutoplayMessageBox = (tabId) => { + const tab = webContents.fromTabID(tabId) + if (!tab || tab.isDestroyed()) { + return + } + const location = tab.getURL() const origin = getOrigin(location) const originSettings = siteSettings.getSiteSettingsForURL(AppStore.getState().get('siteSettings'), origin) if (originSettings && originSettings.get('noAutoplay') === true) { @@ -46,11 +51,8 @@ const showAutoplayMessageBox = (location, tabId) => { if (buttonIndex === 0) { appActions.changeSiteSetting(ruleKey, 'noAutoplay', false) - if (tabId) { - const tab = webContents.fromTabID(tabId) - if (tab && !tab.isDestroyed()) { - return tab.reload() - } + if (tab && !tab.isDestroyed()) { + tab.reload() } } else { if (persist) { @@ -65,7 +67,7 @@ const autoplayReducer = (state, action, immutableAction) => { action = immutableAction || makeImmutable(action) switch (action.get('actionType')) { case appConstants.APP_AUTOPLAY_BLOCKED: - showAutoplayMessageBox(action.get('location'), action.get('tabId')) + showAutoplayMessageBox(action.get('tabId')) break } return state diff --git a/docs/appActions.md b/docs/appActions.md index 292525d89d1..748941775df 100644 --- a/docs/appActions.md +++ b/docs/appActions.md @@ -1025,14 +1025,12 @@ because ESC was pressed. -### autoplayBlocked(location, tabId) +### autoplayBlocked(tabId) Notifies autoplay has been blocked **Parameters** -**location**: `string`, Location of current frame - **tabId**: `number`, Tab id of current frame diff --git a/js/actions/appActions.js b/js/actions/appActions.js index af1fab05b53..c5f8514b71a 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -1285,13 +1285,11 @@ const appActions = { /** * Notifies autoplay has been blocked - * @param {string} location - Location of current frame * @param {number} tabId - Tab id of current frame */ - autoplayBlocked: function (location, tabId) { + autoplayBlocked: function (tabId) { AppDispatcher.dispatch({ actionType: appConstants.APP_AUTOPLAY_BLOCKED, - location, tabId }) } diff --git a/js/components/frame.js b/js/components/frame.js index ff1c43907c4..55f7fad9b1b 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -504,7 +504,7 @@ class Frame extends React.Component { windowActions.setBlockedBy(this.frame, 'noScript', e.details[1]) } if (e.details[0] === 'autoplay') { - appActions.autoplayBlocked(this.frame.get('location'), this.frame.get('tabId')) + appActions.autoplayBlocked(this.frame.get('tabId')) } }) this.webview.addEventListener('did-block-run-insecure-content', (e) => { diff --git a/js/flash.js b/js/flash.js index 95d1887f3fa..7e64c841a38 100644 --- a/js/flash.js +++ b/js/flash.js @@ -80,7 +80,7 @@ module.exports.showFlashMessageBox = (location, tabId) => { if (tabId) { const tab = webContents.fromTabID(tabId) if (tab && !tab.isDestroyed()) { - return tab.reload() + tab.reload() } } } else {