From 61e6e2476b9dece8a5279a33de9c2edab8ddc63e Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Thu, 6 Oct 2016 09:00:33 -0400 Subject: [PATCH] Show bookmarks toolbar automatically if it was disabled after importing bookmarks successfully fix #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 --- app/importer.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/importer.js b/app/importer.js index 314b0abace0..05dfa1568da 100644 --- a/app/importer.js +++ b/app/importer.js @@ -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() @@ -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: [{ @@ -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) } @@ -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() })