@@ -44,10 +44,8 @@ class HomePage extends React.Component {
4444}
4545
4646function remap ( state ) {
47- let status = state . status
48- // Fetch articles
49- let data = JSON . parse ( localStorage . getItem ( 'local' ) )
50- let { folders, articles } = data
47+ let { folders, articles, status } = state
48+
5149 if ( articles == null ) articles = [ ]
5250 articles . sort ( ( a , b ) => {
5351 return new Date ( b . updatedAt ) - new Date ( a . updatedAt )
@@ -112,7 +110,13 @@ function remap (state) {
112110 // 1. team have one folder at least
113111 // or Change IDLE MODE
114112 if ( status . mode === CREATE_MODE ) {
115- var newArticle = _ . findWhere ( articles , { status : 'NEW' } )
113+ let newArticle = _ . findWhere ( articles , { status : 'NEW' } )
114+ let FolderKey = folders [ 0 ] . key
115+ if ( folderFilters . length > 0 ) {
116+ let targetFolder = _ . findWhere ( folders , { name : folderFilters [ 0 ] . value } )
117+ if ( targetFolder != null ) FolderKey = targetFolder . key
118+ }
119+
116120 if ( newArticle == null ) {
117121 newArticle = {
118122 id : null ,
@@ -121,7 +125,7 @@ function remap (state) {
121125 content : '' ,
122126 mode : 'markdown' ,
123127 tags : [ ] ,
124- FolderKey : folders [ 0 ] . key ,
128+ FolderKey : FolderKey ,
125129 status : NEW
126130 }
127131 articles . unshift ( newArticle )
@@ -131,14 +135,12 @@ function remap (state) {
131135 status . mode = IDLE_MODE
132136 }
133137
134- let props = {
138+ return {
135139 folders,
136140 status,
137141 articles,
138142 activeArticle
139143 }
140-
141- return props
142144}
143145
144146HomePage . propTypes = {
0 commit comments