Skip to content

Commit

Permalink
Use addBookmark instead of addSite for bookmarks
Browse files Browse the repository at this point in the history
Fix brave#11033

We currently don't have DND under automated so no extra test coverage.

The js/dnd change is if you drag a bookmark from Chrome to Brave it was
erroring with a JS error before instead of creating the bookmark.  Now
it works.

Auditors: @cezaraugusto
  • Loading branch information
bbondy committed Sep 21, 2017
1 parent 063f110 commit 48fee97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/renderer/components/bookmarks/bookmarksToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class BookmarksToolbar extends React.Component {
const doc = parser.parseFromString(droppedHTML, 'text/html')
const a = doc.querySelector('a')
if (a && a.href) {
appActions.addSite({
appActions.addBookmark({
title: a.innerText,
location: e.dataTransfer.getData('text/plain')
}, siteTags.BOOKMARK)
Expand All @@ -82,7 +82,7 @@ class BookmarksToolbar extends React.Component {

if (e.dataTransfer.files.length > 0) {
Array.from(e.dataTransfer.items).forEach((item) => {
item.getAsString((name) => appActions.addSite({ location: item.type, title: name }, siteTags.BOOKMARK))
item.getAsString((name) => appActions.addBookmark({ location: item.type, title: name }, siteTags.BOOKMARK))
})
return
}
Expand All @@ -92,7 +92,7 @@ class BookmarksToolbar extends React.Component {
.map((x) => x.trim())
.filter((x) => !x.startsWith('#') && x.length > 0)
.forEach((url) =>
appActions.addSite({ location: url }, siteTags.BOOKMARK))
appActions.addBookmark({ location: url }, siteTags.BOOKMARK))
}

onDragEnter (e) {
Expand Down
4 changes: 3 additions & 1 deletion js/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ module.exports.prepareBookmarkDataFromCompatible = (dataTransfer) => {
let bookmark = dndData.getDragData(dataTransfer, dragTypes.BOOKMARK)
if (!bookmark) {
const dragData = dndData.getDragData(dataTransfer, dragTypes.TAB)
windowActions.onFrameBookmark(dragData.get('tabId'))
if (dragData) {
windowActions.onFrameBookmark(dragData.get('tabId'))
}
}
return bookmark
}

0 comments on commit 48fee97

Please sign in to comment.