Skip to content

Commit

Permalink
Show bookmarks toolbar automatically if it was disabled after importi…
Browse files Browse the repository at this point in the history
…ng bookmarks successfully

fix brave#4507

Auditors: @bbondy

Test Plan:
1. Make sure bookmakrs toolbar doesn't show
2. Import bookmarks from browser
3. bookmarks toolbar will show after successful import

1. Make sure bookmakrs toolbar doesn't show
2. Import bookmarks from html
3. bookmarks toolbar will show after successful import

1. Make sure bookmakrs toolbar doesn't show
2. Make sure there already exist some bookmarks
3. Import bookmarks from browser
4. bookmarks toolbar should not show after successful import

1. Make sure bookmakrs toolbar doesn't show
2. Make sure there already exist some bookmarks
3. Import bookmarks from html
4. bookmarks toolbar should not show after successful import
  • Loading branch information
darkdh committed Oct 6, 2016
1 parent e8bf42e commit 61e6e24
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ const AppStore = require('../js/stores/appStore')
const siteTags = require('../js/constants/siteTags')
const appActions = require('../js/actions/appActions')
const messages = require('../js/constants/messages')
const settings = require('../js/constants/settings')
const getSetting = require('../js/settings').getSetting

var isMergeFavorites = false
var isImportingBookmarks = false
var hasBookmarks

exports.init = () => {
importer.initialize()
Expand All @@ -27,15 +31,27 @@ exports.importData = (selected) => {
if (selected.get('mergeFavorites')) {
isMergeFavorites = true
}
if (selected.get('favorites')) {
isImportingBookmarks = true
const sites = AppStore.getState().get('sites')
hasBookmarks = sites.find(
(site) => siteUtil.isBookmark(site) || siteUtil.isFolder(site)
)
}
if (selected !== undefined) {
importer.importData(selected.toJS())
}
}

exports.importHTML = (selected) => {
isImportingBookmarks = true
if (selected.get('mergeFavorites')) {
isMergeFavorites = true
}
const sites = AppStore.getState().get('sites')
hasBookmarks = sites.find(
(site) => siteUtil.isBookmark(site) || siteUtil.isFolder(site)
)
const files = dialog.showOpenDialog({
properties: ['openFile'],
filters: [{
Expand All @@ -51,6 +67,7 @@ exports.importHTML = (selected) => {

importer.on('update-supported-browsers', (e, detail) => {
isMergeFavorites = false
isImportingBookmarks = false
if (BrowserWindow.getFocusedWindow()) {
BrowserWindow.getFocusedWindow().webContents.send(messages.IMPORTER_LIST, detail)
}
Expand Down Expand Up @@ -203,6 +220,12 @@ importer.on('show-warning-dialog', (e) => {
})

importer.on('import-success', (e) => {
if (isImportingBookmarks) {
const showBookmarksToolbar = getSetting(settings.SHOW_BOOKMARKS_TOOLBAR)
if (!showBookmarksToolbar && !hasBookmarks) {
appActions.changeSetting(settings.SHOW_BOOKMARKS_TOOLBAR, true)
}
}
showImportSuccess()
})

Expand Down

0 comments on commit 61e6e24

Please sign in to comment.