@@ -217,31 +217,49 @@ class FinderMain extends React.Component {
217217 }
218218
219219 render ( ) {
220- let { storages , notes , config } = this . props
220+ let { data , config } = this . props
221221 let { filter, search } = this . state
222- let storageList = storages
223- . map ( ( storage ) => < StorageSection
224- filter = { filter }
225- storage = { storage }
226- key = { storage . key }
227- handleStorageButtonClick = { ( e , storage ) => this . handleStorageButtonClick ( e , storage ) }
228- handleFolderButtonClick = { ( e , storage , folder ) => this . handleFolderButtonClick ( e , storage , folder ) }
229- /> )
230- if ( ! filter . includeSnippet && filter . includeMarkdown ) {
231- notes = notes . filter ( ( note ) => note . type === 'MARKDOWN_NOTE' )
232- } else if ( filter . includeSnippet && ! filter . includeMarkdown ) {
233- notes = notes . filter ( ( note ) => note . type === 'SNIPPET_NOTE' )
222+ let storageList = [ ]
223+ for ( let key in data . storageMap ) {
224+ let storage = data . storageMap [ key ]
225+ let item = (
226+ < StorageSection
227+ filter = { filter }
228+ storage = { storage }
229+ key = { storage . key }
230+ handleStorageButtonClick = { ( e , storage ) => this . handleStorageButtonClick ( e , storage ) }
231+ handleFolderButtonClick = { ( e , storage , folder ) => this . handleFolderButtonClick ( e , storage , folder ) }
232+ />
233+ )
234+ storageList . push ( item )
234235 }
236+ let notes = [ ]
237+ let noteIds
235238
236239 switch ( filter . type ) {
237240 case 'STORAGE' :
238- notes = notes . filter ( ( note ) => note . storage === filter . storage )
241+ noteIds = data . storageNoteMap [ filter . storage ]
239242 break
240243 case 'FOLDER' :
241- notes = notes . filter ( ( note ) => note . storage === filter . storage && note . folder === filter . folder )
244+ noteIds = data . folderNoteMap [ filter . storage + '-' + filter . folder ]
242245 break
243246 case 'STARRED' :
244- notes = notes . filter ( ( note ) => note . isStarred )
247+ noteIds = data . starredSet
248+ }
249+ if ( noteIds != null ) {
250+ noteIds . forEach ( ( id ) => {
251+ notes . push ( data . noteMap [ id ] )
252+ } )
253+ } else {
254+ for ( let key in data . noteMap ) {
255+ notes . push ( data . noteMap [ key ] )
256+ }
257+ }
258+
259+ if ( ! filter . includeSnippet && filter . includeMarkdown ) {
260+ notes = notes . filter ( ( note ) => note . type === 'MARKDOWN_NOTE' )
261+ } else if ( filter . includeSnippet && ! filter . includeMarkdown ) {
262+ notes = notes . filter ( ( note ) => note . type === 'SNIPPET_NOTE' )
245263 }
246264
247265 if ( search . trim ( ) . length > 0 ) {
@@ -302,7 +320,7 @@ class FinderMain extends React.Component {
302320 </ div >
303321 </ div >
304322 < NoteList styleName = 'result-list'
305- storages = { storages }
323+ storageMap = { data . storageMap }
306324 notes = { notes }
307325 ref = 'list'
308326 search = { search }
@@ -323,14 +341,6 @@ class FinderMain extends React.Component {
323341}
324342
325343FinderMain . propTypes = {
326- articles : PropTypes . array ,
327- activeArticle : PropTypes . shape ( {
328- key : PropTypes . string ,
329- tags : PropTypes . array ,
330- title : PropTypes . string ,
331- content : PropTypes . string
332- } ) ,
333- status : PropTypes . shape ( ) ,
334344 dispatch : PropTypes . func
335345}
336346
0 commit comments