-
Notifications
You must be signed in to change notification settings - Fork 971
Remove ref dependency from Frame #8336
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* 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/. */ | ||
|
||
const assert = require('assert') | ||
const { makeImmutable, isMap } = require('./immutableUtil') | ||
|
||
const validateState = function (state) { | ||
state = makeImmutable(state) | ||
assert.ok(isMap(state), 'state must be an Immutable.Map') | ||
return state | ||
} | ||
|
||
const contextMenuState = { | ||
setContextMenu: (state, detail) => { | ||
detail = makeImmutable(detail) | ||
state = validateState(state) | ||
|
||
if (!detail) { | ||
if (state.getIn(['contextMenuDetail', 'type']) === 'hamburgerMenu') { | ||
state = state.set('hamburgerMenuWasOpen', true) | ||
} else { | ||
state = state.set('hamburgerMenuWasOpen', false) | ||
} | ||
state = state.delete('contextMenuDetail') | ||
} else { | ||
if (!(detail.get('type') === 'hamburgerMenu' && state.get('hamburgerMenuWasOpen'))) { | ||
state = state.set('contextMenuDetail', detail) | ||
} | ||
state = state.set('hamburgerMenuWasOpen', false) | ||
} | ||
|
||
return state | ||
} | ||
} | ||
|
||
module.exports = contextMenuState |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ const ipc = electron.ipcRenderer | |
// Actions | ||
const appActions = require('../../../../js/actions/appActions') | ||
const windowActions = require('../../../../js/actions/windowActions') | ||
const contextMenus = require('../../../../js/contextMenus') | ||
const getSetting = require('../../../../js/settings').getSetting | ||
|
||
// Components | ||
|
@@ -69,7 +68,7 @@ class Navigator extends ImmutableComponent { | |
}) | ||
} | ||
} else { | ||
navAction.call(this.activeFrame) | ||
navAction.call(this, this.props.activeTab.get('tabId')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't have this in yet. I didn't yet implement redux here, so we have what we have for now, but when I will add redux to it, we will have primitives. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR only removes refs from Frame. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, no problem |
||
} | ||
} | ||
|
||
|
@@ -122,19 +121,29 @@ class Navigator extends ImmutableComponent { | |
} | ||
|
||
onBack (e) { | ||
this.onNav(e, 'canGoBack', 'back', this.activeFrame.goBack) | ||
this.onNav(e, 'canGoBack', 'back', appActions.onGoBack) | ||
} | ||
|
||
onForward (e) { | ||
this.onNav(e, 'canGoForward', 'forward', this.activeFrame.goForward) | ||
this.onNav(e, 'canGoForward', 'forward', appActions.onGoForward) | ||
} | ||
|
||
onBackLongPress (target) { | ||
contextMenus.onBackButtonHistoryMenu(this.activeFrame, this.activeFrame.getHistory(this.props.appState), target) | ||
const activeTab = this.props.activeTab | ||
const rect = target.parentNode.getBoundingClientRect() | ||
appActions.onGoBackLong(activeTab.get('tabId'), { | ||
left: rect.left, | ||
bottom: rect.bottom | ||
}) | ||
} | ||
|
||
onForwardLongPress (target) { | ||
contextMenus.onForwardButtonHistoryMenu(this.activeFrame, this.activeFrame.getHistory(this.props.appState), target) | ||
const activeTab = this.props.activeTab | ||
const rect = target.parentNode.getBoundingClientRect() | ||
appActions.onGoForwardLong(activeTab.get('tabId'), { | ||
left: rect.left, | ||
bottom: rect.bottom | ||
}) | ||
} | ||
|
||
onDragOver (e) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work correctly? It looks like we normally get it using
window
which isn't available hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are correct we are not receiving anything here, that's why I added if typeof undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code updated