Skip to content

Commit 41e1630

Browse files
committed
フォルダーで検索するときに in:じゃなくて /にする +バグ修正
1 parent ef84c4e commit 41e1630

5 files changed

Lines changed: 15 additions & 14 deletions

File tree

browser/finder/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ FinderMain.propTypes = {
119119
function remap (state) {
120120
let { articles, folders, status } = state
121121

122-
let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^#$/)).map(key => {
123-
if (key.match(/^in:.+$/)) {
124-
return {type: FOLDER_FILTER, value: key.match(/^in:(.+)$/)[1]}
122+
let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^\/$/) && !key.match(/^#$/)).map(key => {
123+
if (key.match(/^\/.+$/)) {
124+
return {type: FOLDER_FILTER, value: key.match(/^\/(.+)$/)[1]}
125125
}
126126
if (key.match(/^#(.+)/)) {
127127
return {type: TAG_FILTER, value: key.match(/^#(.+)$/)[1]}
@@ -134,7 +134,7 @@ function remap (state) {
134134

135135
if (folders != null) {
136136
let targetFolders = folders.filter(folder => {
137-
return _.findWhere(folderFilters, {value: folder.name})
137+
return _.find(folderFilters, filter => folder.name.match(new RegExp(`^${filter.value}`)))
138138
})
139139
status.targetFolders = targetFolders
140140

@@ -164,6 +164,7 @@ function remap (state) {
164164
let activeArticle = _.findWhere(articles, {key: status.articleKey})
165165
if (activeArticle == null) activeArticle = articles[0]
166166

167+
console.log(status.search)
167168
return {
168169
articles,
169170
activeArticle,

browser/finder/reducer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ function status (state = initialStatus, action) {
1414
switch (action.type) {
1515
case SELECT_ARTICLE:
1616
state.articleKey = action.data.key
17-
return state
17+
return Object.assign({}, state)
1818
case SEARCH_ARTICLE:
1919
state.search = action.data.input
20-
return state
20+
return Object.assign({}, state)
2121
default:
2222
return state
2323
}

browser/main/HomePage.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ function remap (state) {
143143
})
144144

145145
// Filter articles
146-
let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^#$/)).map(key => {
147-
if (key.match(/^in:.+$/)) {
148-
return {type: FOLDER_FILTER, value: key.match(/^in:(.+)$/)[1]}
146+
let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^\/$/) && !key.match(/^#$/)).map(key => {
147+
if (key.match(/^\/.+/)) {
148+
return {type: FOLDER_FILTER, value: key.match(/^\/(.+)$/)[1]}
149149
}
150150
if (key.match(/^#(.+)/)) {
151151
return {type: TAG_FILTER, value: key.match(/^#(.+)$/)[1]}
@@ -158,7 +158,7 @@ function remap (state) {
158158

159159
if (folders != null) {
160160
let targetFolders = folders.filter(folder => {
161-
return _.findWhere(folderFilters, {value: folder.name})
161+
return _.find(folderFilters, filter => folder.name.match(new RegExp(`^${filter.value}`)))
162162
})
163163
status.targetFolders = targetFolders
164164

@@ -204,7 +204,7 @@ function remap (state) {
204204
let newArticle = _.findWhere(articles, {status: 'NEW'})
205205
let FolderKey = folders[0].key
206206
if (folderFilters.length > 0) {
207-
let targetFolder = _.findWhere(folders, {name: folderFilters[0].value})
207+
let targetFolder = _.find(folders, folder => folder.name.match(new RegExp(`^${folderFilters[0].value}`)))
208208
if (targetFolder != null) FolderKey = targetFolder.key
209209
}
210210

browser/main/HomePage/ArticleTopBar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const searchTutorialElement = (
1010
<text x='450' y='33' fill={BRAND_COLOR} fontSize='24'>Search some posts!!</text>
1111
<text x='450' y='60' fill={BRAND_COLOR} fontSize='18'>{'- Search by tag : #{string}'}</text>
1212
<text x='450' y='85' fill={BRAND_COLOR} fontSize='18'>
13-
{'- Search by folder : in:{folder_name}\n'}</text>
13+
{'- Search by folder : /{folder_name}\n'}</text>
1414

1515
<svg width='500' height='300'>
1616
<path fill='white' d='M54.5,51.5c-12.4,3.3-27.3-1.4-38.4-7C11.2,42,5,38.1,5.6,31.8c0.7-6.9,8.1-11.2,13.8-13.7
@@ -117,7 +117,7 @@ export default class ArticleTopBar extends React.Component {
117117
}
118118
<div className={'tooltip' + (this.state.isTooltipHidden ? ' hide' : '')}>
119119
- Search by tag : #{'{string}'}<br/>
120-
- Search by folder : in:{'{folder_name}'}
120+
- Search by folder : /{'{folder_name}'}
121121
</div>
122122
</div>
123123

lib/reducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function status (state = initialStatus, action) {
131131
return state
132132
case SWITCH_FOLDER:
133133
state.mode = IDLE_MODE
134-
state.search = `in:${action.data} `
134+
state.search = `/${action.data} `
135135

136136
return state
137137
case SWITCH_MODE:

0 commit comments

Comments
 (0)