@@ -5,14 +5,13 @@ import { DropDown, DropdownButton } from '@atoms/dropdown'
5
5
import { IconToggle } from '@atoms/toggles'
6
6
import { SingleViewIcon , MasonryIcon , ChevronIcon } from '@icons'
7
7
8
- import { useState } from 'react'
9
8
import { Button } from '@atoms/button'
10
9
11
10
import { useLocalSettings } from '@context/localSettingsStore'
12
11
import { useLocation , useNavigate } from 'react-router'
13
- import { useEffect } from 'react'
14
12
import { Line } from '@atoms/line'
15
13
import { shallow } from 'zustand/shallow'
14
+ import { FEED_MAP , DEFAULT_START_FEED } from '@constants'
16
15
17
16
// const MediaFilter = ({ label, tagline }) => {
18
17
// return (
@@ -24,54 +23,46 @@ import { shallow } from 'zustand/shallow'
24
23
// }
25
24
26
25
const locationMap = new Map ( [
27
- [ '/' , 'Recent Sales' ] ,
28
- [ '/feed/random' , 'Random' ] ,
29
- [ '/feed/newobjkts' , 'New OBJKTs' ] ,
30
- [ '/feed/friends' , 'Friends' ] ,
26
+ [ '/feed/sales ' , FEED_MAP [ 'Recent Sales' ] ] ,
27
+ [ '/feed/random' , FEED_MAP [ 'Random' ] ] ,
28
+ [ '/feed/newobjkts' , FEED_MAP [ 'New OBJKTs' ] ] ,
29
+ [ '/feed/friends' , FEED_MAP [ 'Friends' ] ] ,
31
30
// separator
32
31
[ '---fund_feeds' , 'fund_feeds' ] ,
33
- [ '/feed/quake-aid' , 'Quake Aid' ] ,
34
- [ '/feed/ukraine' , '🇺🇦 Ukraine' ] ,
35
- [ '/feed/pakistan' , '🇵🇰 Pakistan' ] ,
36
- [ '/feed/iran' , '🇮🇷 Iran' ] ,
37
- [ '/feed/tezospride' , '🏳️🌈 Tezospride' ] ,
32
+ [ '/feed/quake-aid' , FEED_MAP [ 'Quake Aid' ] ] ,
33
+ [ '/feed/ukraine' , FEED_MAP [ '🇺🇦 Ukraine' ] ] ,
34
+ [ '/feed/pakistan' , FEED_MAP [ '🇵🇰 Pakistan' ] ] ,
35
+ [ '/feed/iran' , FEED_MAP [ '🇮🇷 Iran' ] ] ,
36
+ [ '/feed/tezospride' , FEED_MAP [ '🏳️🌈 Tezospride' ] ] ,
38
37
// separator
39
38
[ '---mime_feeds' , 'mime_feeds' ] ,
40
- [ '/feed/image' , 'Image' ] ,
41
- [ '/feed/video' , 'Video' ] ,
42
- [ '/feed/audio' , 'Audio' ] ,
43
- [ '/feed/glb' , '3D' ] ,
44
- [ '/feed/html-svg' , 'HTML & SVG' ] ,
45
- [ '/feed/gif' , 'GIF' ] ,
46
- [ '/feed/pdf' , 'PDF' ] ,
47
- [ '/feed/md' , 'Markdown' ] ,
39
+ [ '/feed/image' , FEED_MAP [ 'Image' ] ] ,
40
+ [ '/feed/video' , FEED_MAP [ 'Video' ] ] ,
41
+ [ '/feed/audio' , FEED_MAP [ 'Audio' ] ] ,
42
+ [ '/feed/glb' , FEED_MAP [ '3D' ] ] ,
43
+ [ '/feed/html-svg' , FEED_MAP [ 'HTML & SVG' ] ] ,
44
+ [ '/feed/gif' , FEED_MAP [ 'GIF' ] ] ,
45
+ [ '/feed/pdf' , FEED_MAP [ 'PDF' ] ] ,
46
+ [ '/feed/md' , FEED_MAP [ 'Markdown' ] ] ,
48
47
] )
49
48
50
49
const locationNeedSync = [ '/feed/friends' ]
51
- const locationPaths = [ ...locationMap . keys ( ) ]
52
50
53
51
export const FeedToolbar = ( { feeds_menu = false } ) => {
54
52
// const [price, setPrice] = useState({ from: 0, to: 0 })
55
53
56
- const [ viewMode , setViewMode ] = useLocalSettings (
57
- ( st ) => [ st . viewMode , st . setViewMode ] ,
54
+ const [ viewMode , setViewMode , startFeed ] = useLocalSettings (
55
+ ( st ) => [ st . viewMode , st . setViewMode , st . startFeed ] ,
58
56
shallow
59
57
)
60
58
const location = useLocation ( )
61
- const [ feedLabel , setFeedLabel ] = useState ( 'Recent Sales' )
59
+ const feedLabel =
60
+ locationMap . get ( location . pathname ) ||
61
+ startFeed ||
62
+ FEED_MAP [ DEFAULT_START_FEED ]
62
63
63
64
const navigate = useNavigate ( )
64
65
65
- useEffect ( ( ) => {
66
- for ( const pth of locationPaths . slice ( 1 ) ) {
67
- if ( location . pathname . includes ( pth ) ) {
68
- setFeedLabel ( locationMap . get ( pth ) )
69
- }
70
- }
71
-
72
- // return locationMap[location]
73
- } , [ location ] )
74
-
75
66
// TODO: finish the filtering logic
76
67
// const filters = false
77
68
return (
0 commit comments