@@ -38,25 +38,15 @@ const showCategory = (categoryToShow) => {
38
38
return
39
39
}
40
40
const url = new URL ( window . location . href )
41
- const currentVisible = new URLSearchParams ( url . search ) . get ( 'visible' ) ?. split ( ',' ) || [ ...possibleFilters ]
41
+ const currentVisible = new URLSearchParams ( url . search ) . get ( 'visible' ) ?. split ( ',' ) . filter ( Boolean ) ||
42
+ [ ...possibleFilters ]
42
43
const settings = [ ...new Set ( [ categoryToShow , ...currentVisible ] ) ]
43
44
const noFilter = possibleFilters . length === settings . length || ! settings . length
44
45
45
46
noFilter ? url . searchParams . delete ( 'visible' ) : url . searchParams . set ( 'visible' , settings . join ( ',' ) )
46
47
history . pushState ( { } , null , unescape ( url . href ) )
47
48
}
48
49
49
- const setFilter = ( currentFilter ) => {
50
- if ( ! possibleFilters . includes ( currentFilter ) ) {
51
- return
52
- }
53
- const url = new URL ( window . location . href )
54
- const settings = [ currentFilter , ...new Set ( new URLSearchParams ( url . search ) . get ( 'filter' ) . split ( ',' ) ) ]
55
-
56
- url . searchParams . set ( 'filter' , settings )
57
- history . pushState ( { } , null , unescape ( url . href ) )
58
- }
59
-
60
50
const getSort = ( initialSort ) => {
61
51
const url = new URL ( window . location . href )
62
52
let sort = new URLSearchParams ( url . search ) . get ( 'sort' )
@@ -103,7 +93,6 @@ const setSortDirection = (ascending) => sessionStorage.setItem('sortAsc', ascend
103
93
104
94
module . exports = {
105
95
getVisible,
106
- setFilter,
107
96
hideCategory,
108
97
showCategory,
109
98
getSort,
0 commit comments