-
Notifications
You must be signed in to change notification settings - Fork 975
Conversation
@@ -111,7 +111,9 @@ class UrlBarIcon extends React.Component { | |||
|
|||
onDragStart (e) { | |||
dndData.setupDataTransferURL(e.dataTransfer, this.props.location, this.props.title) | |||
dndData.setupDataTransferBraveData(e.dataTransfer, dragTypes.TAB, this.props.activeFrame) | |||
dndData.setupDataTransferBraveData(e.dataTransfer, dragTypes.TAB, Immutable.fromJS({ |
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.
conversion to/from JS is a relatively expensive operation, why do we need to send an object instead of just the activeFrameKey value
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.
Because this function expect data to Immutable https://github.com/brave/browser-laptop/blob/master/js/dndData.js#L26. What I can do is add a check in this function and if data is Immutable convert it, otherwise leave it as it is.
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.
that function turns it right back into js again. I think we should stick with regular js
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
48e1584
to
e0827f5
Compare
js/dnd.js
Outdated
appActions.addSite(bookmark, siteTags.BOOKMARK) | ||
} | ||
const frame = dndData.getDragData(dataTransfer, dragTypes.TAB) | ||
windowActions.onFrameBookmark(frame.get('activeFrameKey')) |
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 change actually doesn't make sense to me. There's no state
that is needed here so I don't see any reason to create a window action that forwards to an app action. We are using that anti-pattern in select places where there isn't a good workaround right now, but this doesn't seem necessary. What I think we should do (in another PR) is convert the drop
methods to actions and move this code inside a (preferably browser process) reducer. It also seems like a bad idea to hide an action call inside this method and it should probably just return the bookmark from dndData and do nothing else. I think we're adding a layer of indirection here that is just going to be removed later anyway
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.
Why I moved this into separate action is because we need to get detail of the frame so we can add it into sites.
Here we need to have access to the window state: https://github.com/brave/browser-laptop/pull/9754/files/e0827f5b092eecfbe915b23838fb9dccc8fdcc5b#diff-be01d0957f991e2400072d82d108450fL142
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 the confusing part here is that you're getting frame
from dndData.getDragData
, but apparently that isn't a frame so I think like the other one we should just pass frameKey
. I just noticed this calls frame.get('activeFrameKey')
which makes it even more confusing
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.
Probably the naming is wrong here, so I fixed it. We send activeFrameKey
from this line https://github.com/brave/browser-laptop/pull/9754/files/e0827f5b092eecfbe915b23838fb9dccc8fdcc5b#diff-51a114fecaac13cd41162f4c956e7508R114 and then get it back here as Immutable Map with this function
Line 11 in 26a580b
module.exports.getDragData = (dataTransfer, dragType) => { |
So we don't receive the whole frame, but we send end receive only frameKey
e0827f5
to
5bec429
Compare
5bec429
to
a9f9b0b
Compare
@@ -111,7 +111,9 @@ class UrlBarIcon extends React.Component { | |||
|
|||
onDragStart (e) { | |||
dndData.setupDataTransferURL(e.dataTransfer, this.props.location, this.props.title) | |||
dndData.setupDataTransferBraveData(e.dataTransfer, dragTypes.TAB, this.props.activeFrame) | |||
dndData.setupDataTransferBraveData(e.dataTransfer, dragTypes.TAB, { | |||
activeFrameKey: this.props.activeFrameKey |
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.
sorry to do this to you, but can we use tabId
instead of frameKey
? If we had the tabId
it would be easy to convert this to a browser process action (please add TODO for that) with a siteUtil.getDetailFromTabId
method. I think we should drop active
as well once it gets to this point
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 totally agree and I forget about this one too frequently. Fixed
a9f9b0b
to
1984a85
Compare
Resolves brave#9753 Auditors: @bsclifton @bridiver Test Plan:
comment added |
1984a85
to
1dec383
Compare
++ |
Submitter Checklist:
git rebase -i
to squash commits (if needed).Resolves #9753
Auditors: @bsclifton @bridiver
Test Plan:
Reviewer Checklist:
Tests