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

Commit

Permalink
more tab event / state logging
Browse files Browse the repository at this point in the history
  • Loading branch information
petemill committed Feb 22, 2018
1 parent d547029 commit c817fb0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
11 changes: 10 additions & 1 deletion app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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')
const {shouldDebugTabEvents} = require('../../cmdLine')

const WEBRTC_DEFAULT = 'default'
const WEBRTC_DISABLE_NON_PROXY = 'disable_non_proxied_udp'
Expand Down Expand Up @@ -152,7 +153,15 @@ const tabsReducer = (state, action, immutableAction) => {
break
case appConstants.APP_TAB_REPLACED:
if (action.get('isPermanent')) {
if (shouldDebugTabEvents) {
console.log('APP_TAB_REPLACED before')
tabs.debugTabs(state)
}
state = tabState.replaceTabValue(state, action.get('oldTabId'), action.get('newTabValue'))
if (shouldDebugTabEvents) {
console.log('APP_TAB_REPLACED after')
tabs.debugTabs(state)
}
}
break
case appConstants.APP_TAB_CLOSE_REQUESTED:
Expand Down Expand Up @@ -340,7 +349,7 @@ const tabsReducer = (state, action, immutableAction) => {
break
}
case appConstants.APP_FRAME_CHANGED:
state = tabState.updateFrame(state, action)
state = tabState.updateFrame(state, action, shouldDebugTabEvents)
break
case windowConstants.WINDOW_SET_FRAME_ERROR:
{
Expand Down
3 changes: 3 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,9 @@ const api = {
},

closeTab: (tabId, forceClosePinned = false) => {
if (shouldDebugTabEvents) {
console.log(`[${tabId}] tabs.closeTab(forceClosePinned: ${forceClosePinned})`)
}
const tabValue = getTabValue(tabId)
if (!tabValue) {
return false
Expand Down
15 changes: 12 additions & 3 deletions app/common/state/tabState.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,21 +442,30 @@ const tabState = {
return state.set('tabs', tabs)
},

updateFrame: (state, action) => {
updateFrame: (state, action, shouldDebugTabEvents = false) => {
state = validateState(state)
action = validateAction(action)
const tabId = action.getIn(['frame', 'tabId'])
console.log(`frame changed ${tabId}`)

if (!tabId) {
if (shouldDebugTabEvents) {
console.log(`Tab [${tabId}] frame changed for tab - no tabId provided!`)
}
return state
}

let tabValue = tabState.getByTabId(state, tabId)
if (!tabValue) {
console.log(`Frame changed - tab ${tabId} not found.`)
if (shouldDebugTabEvents) {
console.log(`Tab [${tabId}] frame changed for tab - tab not found in state, probably a temporary frame`)
}
return state
}

if (shouldDebugTabEvents) {
console.log(`Tab [${tabId}] frame changed for tab`)
}

const bookmarkUtil = require('../lib/bookmarkUtil')
const frameLocation = action.getIn(['frame', 'location'])
const frameBookmarked = bookmarkUtil.isLocationBookmarked(state, frameLocation)
Expand Down

0 comments on commit c817fb0

Please sign in to comment.