Sfoglia il codice sorgente

filter in sidebar cannot be stacked

Skylsmoi 6 anni fa
parent
commit
e13f437ecf
1 ha cambiato i file con 5 aggiunte e 9 eliminazioni
  1. 5 9
      src/container/Sidebar.jsx

+ 5 - 9
src/container/Sidebar.jsx Vedi File

@@ -41,23 +41,19 @@ class Sidebar extends React.Component {
41 41
   handleClickWorkspace = (wsId, newIsOpenInSidebar) => this.props.dispatch(setWorkspaceListIsOpenInSidebar(wsId, newIsOpenInSidebar))
42 42
 
43 43
   handleClickAllContent = wsId => {
44
+    this.props.dispatch(updateWorkspaceFilter([]))
45
+
44 46
     this.props.history.push(`${PAGE_NAME.WS_CONTENT}/${wsId}`)
45 47
   }
46 48
 
47 49
   handleClickContentFilter = (wsId, filter) => {
48
-    const { workspaceIdInUrl } = this.state
49 50
     const { workspace, history, dispatch } = this.props
50 51
 
51
-    const filterList = (() => {
52
-      if (wsId !== workspaceIdInUrl) return [filter] // load a different workspace => reset filters
53
-
54
-      if (workspace.filter.includes(filter)) return workspace.filter.filter(f => f !== filter) // remove the filter
55
-      else return [...workspace.filter, filter] // add the filter
56
-    })()
52
+    const newFilter = workspace.filter.includes(filter) ? [] : [filter] // use an array to allow multiple filters (NYI)
57 53
 
58
-    dispatch(updateWorkspaceFilter(filterList))
54
+    dispatch(updateWorkspaceFilter(newFilter))
59 55
 
60
-    history.push(`${PAGE_NAME.WS_CONTENT}/${wsId}/${filterList.join(';')}`) // workspace.filter gets updated on react redraw from match.params
56
+    history.push(`${PAGE_NAME.WS_CONTENT}/${wsId}/${newFilter.join(';')}`) // workspace.filter gets updated on react redraw from match.params
61 57
   }
62 58
 
63 59
   handleClickToggleSidebar = () => this.setState(prev => ({sidebarClose: !prev.sidebarClose}))