-
Notifications
You must be signed in to change notification settings - Fork 974
Removes non-primitive types from UrlBar #9757
Conversation
d5beac9
to
486c202
Compare
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.
Comments left; otherwise, looks great 😄
} | ||
]) | ||
|
||
it('suggestion list is empty', function () { |
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.
😍
(this.props.urlbarLocationSuffix && this.props.autocompleteEnabled))) { | ||
// Hack to make alt enter open a new tab for url bar suggestions when hitting enter on them. | ||
const isDarwin = process.platform === 'darwin' | ||
if (e.altKey) { | ||
if (isDarwin) { |
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.
the isDarwin
that is inside platformUtil is a little different than the one which was removed; it's actually a function that needs to be called (as opposed to the one that was removed above (which only checks process.platform). This is because platformUtil is safe to use in the renderer (which doesn't have access to node (ex: process.platform
). Instead, it checks navigator.platform
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.
isDarwin = () => {
return process.platform === 'darwin' ||
navigator.platform === 'MacIntel'
}
it first checks process.platform === 'darwin'
same as we did in the removed code. Isn't then this the same or can navigator.platform === 'MacIntel'
lead into wrong determination of the OS?
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.
@NejcZdovc the check in platformUtil has been tested well in both the browser and renderer process. Typically, if you're in the renderer, process.platform
will return undefined
- hence the need to also check navigator.platform
(which IS set in the renderer)
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.
Using this utility method is encouraged over duplicating the code (especially since it has tests 😄 )
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.
fixed
@@ -125,11 +118,10 @@ class UrlBar extends React.Component { | |||
const isLocationUrl = isUrl(location) | |||
if (!isLocationUrl && e.ctrlKey) { | |||
appActions.loadURLRequested(this.props.activeTabId, `www.${location}.com`) | |||
} else if (this.shouldRenderUrlBarSuggestions && | |||
((typeof this.activeIndex === 'number' && this.activeIndex >= 0) || | |||
} else if (this.props.showrUrlBarSuggestions && |
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.
misspelling here; s/showrUrlBarSuggestions/showUrlBarSuggestions/g
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.
done
@@ -144,7 +139,8 @@ class NavigationBar extends React.Component { | |||
props.showHomeButton = !props.titleMode && getSetting(settings.SHOW_HOME_BUTTON) | |||
|
|||
// used in other functions | |||
props.navbar = navbar // TODO(nejc) remove, primitives only | |||
props.isFocused = navbar.getIn(['urlbar', 'focused']) |
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.
should this have a default (in case null, etc)? ex:
props.isFocused = navbar.getIn(['urlbar', 'focused'], false)
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.
We only use it in if statement, so we don't need it, but I added it anyway 😃
e66733c
to
47f4af6
Compare
@bsclifton can we merged this one? |
@@ -428,6 +398,16 @@ class UrlBar extends React.Component { | |||
contextMenus.onUrlBarContextMenu(e) | |||
} | |||
|
|||
onStop () { | |||
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_STOP) |
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.
I don't like duplicating this logic here. Can we create windowActions.onStop
and have both methods call that instead?
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.
So just move the whole content of this function into another window action?
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.
yea, that will have the added benefit of calling one windowAction instead of 2. You can refactor WINDOW_SET_URL_BAR_SELECTED
and WINDOW_SET_URL_BAR_ACTIVE
handlers in urlBarReducer into methods so you can call them from WINDOW_ON_STOP
. In a follow-up we can get rid of SHORTCUT_ACTIVE_FRAME_STOP
and replace it with a WINDOW_ON_STOP
handler in the browser process
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.
sendToFocusedWindow
also needs to die eventually :)
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.
Done
47f4af6
to
c33d345
Compare
@@ -83,17 +83,7 @@ class NavigationBar extends React.Component { | |||
|
|||
onStop () { | |||
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_STOP) |
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.
I think we should put this ipc message in there as well. When we get rid of it, we'll just switch over to the browser process handling WINDOW_ON_STOP
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.
problem is that ipc.emit
is not working in urlBarReducer
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.
as pre our discussion, I added TODO's, so that we remove this shortcut.
Resolves brave#9756 Auditors: @bsclifton @bbondy Test Plan:
c33d345
to
7588a3c
Compare
++ |
Submitter Checklist:
git rebase -i
to squash commits (if needed).Resolves #9756
Auditors: @bridiver @bbondy
Test Plan:
Reviewer Checklist:
Tests