kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Fix refresh error
rodzic
b0ff170e88
commit
2778209fd2
|
@ -1,7 +1,7 @@
|
||||||
import globeIcon from '@tabler/icons/outline/globe.svg';
|
import globeIcon from '@tabler/icons/outline/globe.svg';
|
||||||
import trendIcon from '@tabler/icons/outline/trending-up.svg';
|
import trendIcon from '@tabler/icons/outline/trending-up.svg';
|
||||||
import userIcon from '@tabler/icons/outline/user.svg';
|
import userIcon from '@tabler/icons/outline/user.svg';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import { Route, Switch, useLocation } from 'react-router-dom';
|
import { Route, Switch, useLocation } from 'react-router-dom';
|
||||||
import { useNavigate } from 'react-router-dom-v5-compat';
|
import { useNavigate } from 'react-router-dom-v5-compat';
|
||||||
|
@ -100,11 +100,20 @@ const SearchPage = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const path = useLocation().pathname;
|
||||||
const [selectedFilter, setSelectedFilter] = useState('global');
|
|
||||||
|
|
||||||
const selectFilter = (newActiveFilter: SearchFilter) => dispatch(setFilter(newActiveFilter));
|
const selectFilter = (newActiveFilter: SearchFilter) => dispatch(setFilter(newActiveFilter));
|
||||||
|
|
||||||
|
const selectedValue = useMemo(() => {
|
||||||
|
if (path === '/explorer') return 'posts';
|
||||||
|
if (path === '/explorer/trends') return 'statuses';
|
||||||
|
dispatch(setFilter('accounts'));
|
||||||
|
return 'accounts';
|
||||||
|
}, [path, dispatch]);
|
||||||
|
|
||||||
|
|
||||||
|
const [selectedFilter, setSelectedFilter] = useState(selectedValue);
|
||||||
|
|
||||||
const renderFilterBar = () => {
|
const renderFilterBar = () => {
|
||||||
const items = [];
|
const items = [];
|
||||||
|
|
||||||
|
@ -116,7 +125,7 @@ const SearchPage = () => {
|
||||||
} else {
|
} else {
|
||||||
dispatch(setFilter('statuses'));
|
dispatch(setFilter('statuses'));
|
||||||
}
|
}
|
||||||
setSelectedFilter(filter ?? 'global');
|
setSelectedFilter(filter ?? 'posts');
|
||||||
navigate(`/explorer${path}`);
|
navigate(`/explorer${path}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,7 +133,7 @@ const SearchPage = () => {
|
||||||
{
|
{
|
||||||
text: intl.formatMessage(messages.statuses),
|
text: intl.formatMessage(messages.statuses),
|
||||||
action: () => handleTabs(''),
|
action: () => handleTabs(''),
|
||||||
name: 'global',
|
name: 'posts',
|
||||||
icon: globeIcon,
|
icon: globeIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -463,7 +463,6 @@
|
||||||
"column_forbidden.body": "You do not have permission to access this page.",
|
"column_forbidden.body": "You do not have permission to access this page.",
|
||||||
"column_forbidden.title": "Forbidden",
|
"column_forbidden.title": "Forbidden",
|
||||||
"common.cancel": "Cancel",
|
"common.cancel": "Cancel",
|
||||||
"common.search": "Search",
|
|
||||||
"compare_history_modal.header": "Edit history",
|
"compare_history_modal.header": "Edit history",
|
||||||
"compose.character_counter.title": "Used {chars} out of {maxChars} {maxChars, plural, one {character} other {characters}}",
|
"compose.character_counter.title": "Used {chars} out of {maxChars} {maxChars, plural, one {character} other {characters}}",
|
||||||
"compose.edit_success": "Your post was edited",
|
"compose.edit_success": "Your post was edited",
|
||||||
|
|
Ładowanie…
Reference in New Issue