Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4587 from darkdh/4507
Browse files Browse the repository at this point in the history
Show bookmarks toolbar automatically if it was disabled after importing bookmarks successfully
  • Loading branch information
bbondy authored Oct 6, 2016
2 parents e8bf42e + 61e6e24 commit 99a205b
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 99a205b

Please sign in to comment.