@@ -131,6 +131,23 @@ ipcMain.on(messages.ABOUT_COMPONENT_INITIALIZED, (e) => {
131
131
} )
132
132
} )
133
133
134
+ const getBookmarksData = function ( state ) {
135
+ let bookmarkSites = new Immutable . Map ( )
136
+ let bookmarkFolderSites = new Immutable . Map ( )
137
+ state . get ( 'sites' ) . forEach ( ( site , siteKey ) => {
138
+ const tags = site . get ( 'tags' )
139
+ if ( tags . includes ( siteTags . BOOKMARK ) ) {
140
+ bookmarkSites = bookmarkSites . set ( siteKey , site )
141
+ }
142
+ if ( tags . includes ( siteTags . BOOKMARK_FOLDER ) ) {
143
+ bookmarkFolderSites = bookmarkFolderSites . set ( siteKey , site )
144
+ }
145
+ } )
146
+ const bookmarks = bookmarkSites . toList ( ) . sort ( siteUtil . siteSort ) . toJS ( )
147
+ const bookmarkFolders = bookmarkFolderSites . toList ( ) . sort ( siteUtil . siteSort ) . toJS ( )
148
+ return { bookmarks, bookmarkFolders}
149
+ }
150
+
134
151
const updateAboutDetails = ( tab , tabValue ) => {
135
152
const appState = appStore . getState ( )
136
153
const url = getSourceAboutUrl ( tab . getURL ( ) )
@@ -146,8 +163,6 @@ const updateAboutDetails = (tab, tabValue) => {
146
163
allSiteSettings = allSiteSettings . mergeDeep ( appState . get ( 'temporarySiteSettings' ) )
147
164
}
148
165
const extensionsValue = appState . get ( 'extensions' )
149
- const bookmarks = appState . get ( 'sites' ) . filter ( ( site ) => site . get ( 'tags' ) . includes ( siteTags . BOOKMARK ) ) . toList ( ) . sort ( siteUtil . siteSort )
150
- const bookmarkFolders = appState . get ( 'sites' ) . filter ( ( site ) => site . get ( 'tags' ) . includes ( siteTags . BOOKMARK_FOLDER ) ) . toList ( ) . sort ( siteUtil . siteSort )
151
166
const sync = appState . get ( 'sync' )
152
167
const braveryDefaults = siteSettings . braveryDefaults ( appState , appConfig )
153
168
const history = aboutHistoryState . getHistory ( appState )
@@ -170,11 +185,11 @@ const updateAboutDetails = (tab, tabValue) => {
170
185
tab . send ( messages . SYNC_UPDATED , sync . toJS ( ) )
171
186
tab . send ( messages . BRAVERY_DEFAULTS_UPDATED , braveryDefaults )
172
187
tab . send ( messages . EXTENSIONS_UPDATED , extensionsValue . toJS ( ) )
173
- } else if ( location === 'about:bookmarks' && bookmarks ) {
174
- tab . send ( messages . BOOKMARKS_UPDATED , {
175
- bookmarks : bookmarks . toJS ( ) ,
176
- bookmarkFolders : bookmarkFolders . toJS ( )
177
- } )
188
+ } else if ( location === 'about:bookmarks' ) {
189
+ const bookmarksData = getBookmarksData ( appState )
190
+ if ( bookmarksData . bookmarks ) {
191
+ tab . send ( messages . BOOKMARKS_UPDATED , bookmarksData )
192
+ }
178
193
} else if ( location === 'about:history' ) {
179
194
if ( ! history ) {
180
195
appActions . populateHistory ( )
0 commit comments