kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Refactor: Clean up code and remove unnecessary lines
rodzic
5960f1bc49
commit
2f48bf83b7
|
@ -107,10 +107,14 @@ const SearchPage = () => {
|
||||||
const selectedValue = useMemo(() => {
|
const selectedValue = useMemo(() => {
|
||||||
if (path === '/explorer') return 'posts';
|
if (path === '/explorer') return 'posts';
|
||||||
if (path === '/explorer/trends') return 'statuses';
|
if (path === '/explorer/trends') return 'statuses';
|
||||||
dispatch(setFilter('accounts'));
|
|
||||||
return 'accounts';
|
return 'accounts';
|
||||||
}, [path, dispatch]);
|
}, [path]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedValue === 'accounts') {
|
||||||
|
dispatch(setFilter('accounts'));
|
||||||
|
}
|
||||||
|
}, [selectedValue, dispatch]);
|
||||||
|
|
||||||
const [selectedFilter, setSelectedFilter] = useState(selectedValue);
|
const [selectedFilter, setSelectedFilter] = useState(selectedValue);
|
||||||
|
|
||||||
|
@ -121,9 +125,8 @@ const SearchPage = () => {
|
||||||
if (filter) {
|
if (filter) {
|
||||||
selectFilter(filter);
|
selectFilter(filter);
|
||||||
dispatch(clearSearch());
|
dispatch(clearSearch());
|
||||||
dispatch(setFilter(filter));
|
|
||||||
} else {
|
} else {
|
||||||
dispatch(setFilter('statuses'));
|
selectFilter('statuses');
|
||||||
}
|
}
|
||||||
setSelectedFilter(filter ?? 'posts');
|
setSelectedFilter(filter ?? 'posts');
|
||||||
navigate(`/explorer${path}`);
|
navigate(`/explorer${path}`);
|
||||||
|
@ -163,7 +166,6 @@ const SearchPage = () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path={'/'} component={PostsTab} />
|
|
||||||
<Route exact path={'/explorer'} component={PostsTab} />
|
<Route exact path={'/explorer'} component={PostsTab} />
|
||||||
<Route path={'/explorer/trends'} component={TrendsTab} />
|
<Route path={'/explorer/trends'} component={TrendsTab} />
|
||||||
<Route path={'/explorer/accounts'} component={AccountsTab} />
|
<Route path={'/explorer/accounts'} component={AccountsTab} />
|
||||||
|
|
Ładowanie…
Reference in New Issue