From ce89a34a7e44e0f7196efd06801792c562e8fa06 Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Sun, 25 Sep 2016 01:29:50 +0800 Subject: [PATCH] Update favicon from importer fix #4720 Auditors: @bbondy Test Plan: 1. Make sure "Favicons" in "about:preferences#general" is on 2. Import bookmarks from other browser or html file 3. There should be favicon for bookmarks --- app/importer.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/importer.js b/app/importer.js index af7bf7c0949..8920e85e26c 100644 --- a/app/importer.js +++ b/app/importer.js @@ -148,6 +148,20 @@ importer.on('add-bookmarks', (e, bookmarks, topLevelFolder) => { }) importer.on('add-favicons', (e, detail) => { + let faviconMap = {} + detail.forEach((entry) => { + faviconMap[entry.urls[0]] = entry.favicon_url + }) + let sites = AppStore.getState().get('sites') + sites = sites.map((site) => { + if (site.get('favicon') === undefined && site.get('location') !== undefined && + faviconMap[site.get('location')] !== undefined) { + return site.set('favicon', faviconMap[site.get('location')]) + } else { + return site + } + }) + appActions.addSite(sites) }) importer.on('add-keywords', (e, templateUrls, uniqueOnHostAndPath) => {