Add clear button to topic search

This commit is contained in:
Thomas Nordquist
2019-01-22 16:43:25 +01:00
parent 28cc72a868
commit be8e05dbfa
7 changed files with 57 additions and 18 deletions

View File

@@ -26,23 +26,20 @@ export const setTopicOrder = (topicOrder: TopicOrder = TopicOrder.none): Action
}
export const filterTopics = (filterStr: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
const topicFilter = filterStr.toLowerCase()
const { tree } = getState().connection
dispatch({
topicFilter,
topicFilter: filterStr,
type: ActionTypes.SETTINGS_FILTER_TOPICS,
})
const { tree } = getState().connection
if (!tree) {
return
}
if (!topicFilter) {
if (!filterStr || !tree) {
dispatch(showTree(tree))
return
}
const topicFilter = filterStr.toLowerCase()
const nodeFilter = (node: q.TreeNode): boolean => {
const topicMatches = node.path().toLowerCase().indexOf(topicFilter) !== -1
if (topicMatches) {