Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #12376 from NejcZdovc/hotfix/#12375-reload
Browse files Browse the repository at this point in the history
Fixes reload
  • Loading branch information
bsclifton committed Dec 22, 2017
1 parent 16f13f1 commit 9c7756b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
8 changes: 4 additions & 4 deletions app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const windows = require('../windows')
const {getWebContents} = require('../webContentsCache')
const {BrowserWindow} = require('electron')
const tabState = require('../../common/state/tabState')
const tabActions = require('../../common/actions/tabActions')
const siteSettings = require('../../../js/state/siteSettings')
const siteSettingsState = require('../../common/state/siteSettingsState')
const windowConstants = require('../../../js/constants/windowConstants')
Expand All @@ -21,6 +20,7 @@ const {getFlashResourceId} = require('../../../js/flash')
const {l10nErrorText} = require('../../common/lib/httpUtil')
const Immutable = require('immutable')
const dragTypes = require('../../../js/constants/dragTypes')
const tabActionConsts = require('../../common/constants/tabAction')
const flash = require('../../../js/flash')
const {frameOptsFromFrame} = require('../../../js/state/frameStateUtil')
const {isSourceAboutUrl, isTargetAboutUrl, isNavigatableAboutPage} = require('../../../js/lib/appUrlUtil')
Expand Down Expand Up @@ -48,8 +48,8 @@ const getWebRTCPolicy = (state, tabId) => {
const tabsReducer = (state, action, immutableAction) => {
action = immutableAction || makeImmutable(action)
switch (action.get('actionType')) {
case tabActions.didStartNavigation.name:
case tabActions.didFinishNavigation.name:
case tabActionConsts.FINISH_NAVIGATION:
case tabActionConsts.START_NAVIGATION:
{
const tabId = action.get('tabId')
state = tabState.setNavigationState(state, tabId, action.get('navigationState'))
Expand All @@ -58,7 +58,7 @@ const tabsReducer = (state, action, immutableAction) => {
})
break
}
case tabActions.reload.name:
case tabActionConsts.RELOAD:
{
const tabId = tabState.resolveTabId(state, action.get('tabId'))
setImmediate(() => {
Expand Down
13 changes: 7 additions & 6 deletions app/common/actions/tabActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
'use strict'

const dispatchAction = require('../../common/dispatcher/dispatchAction')
const tabActionConstants = require('../../common/constants/tabAction')

const tabActions = {
// TODO(bridiver) - this is an action anti-pattern and the code that uses it should be refactored
// to be declarative
reload: function tabActionsReload (tabId, ignoreCache) {
dispatchAction(tabActions.reload.name, {
reload: (tabId, ignoreCache) => {
dispatchAction(tabActionConstants.RELOAD, {
tabId,
ignoreCache
})
},

didFinishNavigation: function tabActionsDidFinishNavigation (tabId, navigationState, windowId) {
dispatchAction(tabActions.didFinishNavigation.name, {
didFinishNavigation: (tabId, navigationState, windowId) => {
dispatchAction(tabActionConstants.FINISH_NAVIGATION, {
tabId,
navigationState,
queryInfo: {
Expand All @@ -26,8 +27,8 @@ const tabActions = {
})
},

didStartNavigation: function tabActionsDidStartNavigation (tabId, navigationState, windowId) {
dispatchAction(tabActions.didFinishNavigation.name, {
didStartNavigation: (tabId, navigationState, windowId) => {
dispatchAction(tabActionConstants.START_NAVIGATION, {
tabId,
navigationState,
queryInfo: {
Expand Down
9 changes: 9 additions & 0 deletions app/common/constants/tabAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

module.exports = {
RELOAD: 'tabActionsReload',
FINISH_NAVIGATION: 'tabActionsDidFinishNavigation',
START_NAVIGATION: 'tabActionsDidStartNavigation'
}
8 changes: 4 additions & 4 deletions test/unit/app/browser/reducers/tabsReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const assert = require('assert')
const mockery = require('mockery')
const sinon = require('sinon')
const appConstants = require('../../../../../js/constants/appConstants')
const tabActions = require('../../../../../app/common/actions/tabActions')
const tabActionsConsts = require('../../../../../app/common/constants/tabAction')
const dragTypes = require('../../../../../js/constants/dragTypes')
const fakeElectron = require('../../../lib/fakeElectron')
const fakeAdBlock = require('../../../lib/fakeAdBlock')
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('tabsReducer unit tests', function () {
this.tabId = 1

this.action = {
actionType: tabActions.reload.name,
actionType: tabActionsConsts.RELOAD,
tabId: this.tabId
}
this.reload = sinon.spy()
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('tabsReducer unit tests', function () {
}

const action = {
actionType: tabActions.didFinishNavigation.name,
actionType: tabActionsConsts.FINISH_NAVIGATION,
tabId: this.tabId,
navigationState: this.navigationState
}
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('tabsReducer unit tests', function () {
}

const action = {
actionType: tabActions.didStartNavigation.name,
actionType: tabActionsConsts.START_NAVIGATION,
tabId: this.tabId,
navigationState: this.navigationState
}
Expand Down

0 comments on commit 9c7756b

Please sign in to comment.