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

Commit

Permalink
Remove sync calls for canGoBack and canGoForward
Browse files Browse the repository at this point in the history
Auditors: @bridiver
  • Loading branch information
bbondy committed Jan 25, 2017
1 parent 95ade41 commit 6f9682a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 49 deletions.
7 changes: 6 additions & 1 deletion app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const cleanupWebContents = (tabId) => {
const getTabValue = function (tabId) {
let tab = api.getWebContents(tabId)
if (tab) {
const tabValue = makeImmutable(extensions.tabValue(tab))
let tabValue = makeImmutable(extensions.tabValue(tab))
tabValue = tabValue.set('canGoBack', tab.canGoBack())
tabValue = tabValue.set('canGoForward', tab.canGoForward())
return tabValue.set('tabId', tabId)
}
}
Expand Down Expand Up @@ -129,6 +131,9 @@ const api = {
tab.on('did-navigate', function (evt, url) {
updateTab(tabId)
})
tab.on('did-navigate-in-page', function (evt, url, isMainFrame) {
updateTab(tabId)
})
tab.on('load-start', function (evt, url, isMainFrame, isErrorPage) {
if (isMainFrame) {
updateTab(tabId)
Expand Down
4 changes: 2 additions & 2 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ AppStore
windowId: number, // the windowId that contains the tab
audible: boolean, // is audio playing (muted or not)
muted: boolean, // is the tab muted
canGoBack: boolean, // the tab can be navigated back
canGoForward: boolean // the tab can be navigated forward
}],
windows: [{
// persistent properties
Expand Down Expand Up @@ -295,8 +297,6 @@ WindowStore
frames: [{
audioMuted: boolean, // frame is muted
audioPlaybackActive: boolean, // frame is playing audio
canGoBack: boolean,
canGoForward: boolean,
icon: string, // favicon url
location: string, // The currently navigated location
src: string, // The iframe src attribute
Expand Down
14 changes: 0 additions & 14 deletions docs/windowActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,20 +297,6 @@ Dispatches a message to the store to set the tab page index.



### updateBackForwardState(frameProps, canGoBack, canGoForward)

Dispatches a message to the store to update the back-forward information.

**Parameters**

**frameProps**: `Object`, the frame properties for the webview in question.

**canGoBack**: `boolean`, Specifies if the active frame has previous entries in its history

**canGoForward**: `boolean`, Specifies if the active frame has next entries in its history (i.e. the user pressed back at least once)



### setIsBeingDraggedOverDetail(dragType, dragOverKey, dragDetail)

Dispatches a message to the store to indicate that something is dragging over this item.
Expand Down
16 changes: 0 additions & 16 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,22 +426,6 @@ const windowActions = {
})
},

/**
* Dispatches a message to the store to update the back-forward information.
*
* @param {Object} frameProps - the frame properties for the webview in question.
* @param {boolean} canGoBack - Specifies if the active frame has previous entries in its history
* @param {boolean} canGoForward - Specifies if the active frame has next entries in its history (i.e. the user pressed back at least once)
*/
updateBackForwardState: function (frameProps, canGoBack, canGoForward) {
dispatch({
actionType: windowConstants.WINDOW_UPDATE_BACK_FORWARD,
frameProps,
canGoBack,
canGoForward
})
},

/**
* Dispatches a message to the store to indicate that something is dragging over this item.
*
Expand Down
5 changes: 0 additions & 5 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -816,11 +816,6 @@ class Frame extends ImmutableComponent {
return
}
windowActions.onWebviewLoadEnd(this.frame, url)
windowActions.updateBackForwardState(
this.frame,
this.webview.canGoBack(),
this.webview.canGoForward())

const parsedUrl = urlParse(this.props.location)
if (!this.allowRunningWidevinePlugin()) {
this.showWidevineNotification(this.props.location, this.origin, () => {
Expand Down
10 changes: 6 additions & 4 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ class Main extends ImmutableComponent {
const autofillCreditCardPanelIsVisible = this.props.windowState.get('autofillCreditCardDetail')
const activeRequestedLocation = this.activeRequestedLocation
const noScriptIsVisible = this.props.windowState.getIn(['ui', 'noScriptInfo', 'isVisible'])
const activeTab = activeFrame ? this.props.appState.get('tabs').find((tab) => tab.get('tabId') === activeFrame.get('tabId')) : null
const releaseNotesIsVisible = this.props.windowState.getIn(['ui', 'releaseNotes', 'isVisible'])
const checkDefaultBrowserDialogIsVisible =
isFocused() && defaultBrowserState.shouldDisplayDialog(this.props.appState)
Expand Down Expand Up @@ -955,25 +956,25 @@ class Main extends ImmutableComponent {
<div className={cx({
navigationButtonContainer: true,
nav: true,
disabled: !activeFrame || !activeFrame.get('canGoBack')
disabled: !activeTab || !activeTab.get('canGoBack')
})}>
<LongPressButton
l10nId='backButton'
className='navigationButton backButton'
disabled={!activeFrame || !activeFrame.get('canGoBack')}
disabled={!activeTab || !activeTab.get('canGoBack')}
onClick={this.onBack}
onLongPress={this.onBackLongPress}
/>
</div>
<div className={cx({
navigationButtonContainer: true,
nav: true,
disabled: !activeFrame || !activeFrame.get('canGoForward')
disabled: !activeTab || !activeTab.get('canGoForward')
})}>
<LongPressButton
l10nId='forwardButton'
className='navigationButton forwardButton'
disabled={!activeFrame || !activeFrame.get('canGoForward')}
disabled={!activeTab || !activeTab.get('canGoForward')}
onClick={this.onForward}
onLongPress={this.onForwardLongPress}
/>
Expand Down Expand Up @@ -1242,6 +1243,7 @@ class Main extends ImmutableComponent {
location={frame.get('location')}
isPrivate={frame.get('isPrivate')}
partitionNumber={frame.get('partitionNumber')}
tabData={this.props.appState.get('tabs').find((tab) => tab.get('tabId') === frame.get('tabId'))}
activeShortcut={frame.get('activeShortcut')}
activeShortcutDetails={frame.get('activeShortcutDetails')}
provisionalLocation={frame.get('provisionalLocation')}
Expand Down
1 change: 0 additions & 1 deletion js/constants/windowConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const windowConstants = {
WINDOW_SET_IS_BEING_DRAGGED_OVER_DETAIL: _,
WINDOW_TAB_MOVE: _,
WINDOW_SET_THEME_COLOR: _,
WINDOW_UPDATE_BACK_FORWARD: _,
WINDOW_WEBVIEW_LOAD_END: _,
WINDOW_SET_FULL_SCREEN: _,
WINDOW_SET_LINK_HOVER_PREVIEW: _,
Expand Down
6 changes: 0 additions & 6 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,6 @@ const doAction = (action) => {
updateTabPageIndex(action.frameProps)
}
break
case windowConstants.WINDOW_UPDATE_BACK_FORWARD:
windowState = windowState.mergeIn(['frames', frameStateUtil.getFramePropsIndex(windowState.get('frames'), action.frameProps)], {
canGoBack: action.canGoBack,
canGoForward: action.canGoForward
})
break
case windowConstants.WINDOW_SET_IS_BEING_DRAGGED_OVER_DETAIL:
if (!action.dragOverKey) {
windowState = windowState.deleteIn(['ui', 'dragging'])
Expand Down

0 comments on commit 6f9682a

Please sign in to comment.