kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Restore tabs for Posts and People
rodzic
6dd9050e6c
commit
fce6cbb93d
|
@ -1,22 +1,26 @@
|
||||||
|
import xIcon from '@tabler/icons/outline/x.svg';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import {
|
import {
|
||||||
FormattedMessage,
|
FormattedMessage,
|
||||||
// defineMessages,
|
defineMessages,
|
||||||
// useIntl
|
useIntl,
|
||||||
} from 'react-intl';
|
} from 'react-intl';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
expandSearch,
|
expandSearch,
|
||||||
// setFilter,
|
setFilter,
|
||||||
// setSearchAccount
|
setSearchAccount,
|
||||||
} from 'soapbox/actions/search.ts';
|
} from 'soapbox/actions/search.ts';
|
||||||
import { expandTrendingStatuses, fetchTrendingStatuses } from 'soapbox/actions/trending-statuses.ts';
|
import { expandTrendingStatuses, fetchTrendingStatuses } from 'soapbox/actions/trending-statuses.ts';
|
||||||
// import { useAccount } from 'soapbox/api/hooks/index.ts';
|
import { useAccount } from 'soapbox/api/hooks/index.ts';
|
||||||
import Hashtag from 'soapbox/components/hashtag.tsx';
|
import Hashtag from 'soapbox/components/hashtag.tsx';
|
||||||
|
import IconButton from 'soapbox/components/icon-button.tsx';
|
||||||
import ScrollableList from 'soapbox/components/scrollable-list.tsx';
|
import ScrollableList from 'soapbox/components/scrollable-list.tsx';
|
||||||
|
import HStack from 'soapbox/components/ui/hstack.tsx';
|
||||||
import Spinner from 'soapbox/components/ui/spinner.tsx';
|
import Spinner from 'soapbox/components/ui/spinner.tsx';
|
||||||
// import Tabs from 'soapbox/components/ui/tabs.tsx';
|
import Tabs from 'soapbox/components/ui/tabs.tsx';
|
||||||
|
import Text from 'soapbox/components/ui/text.tsx';
|
||||||
import AccountContainer from 'soapbox/containers/account-container.tsx';
|
import AccountContainer from 'soapbox/containers/account-container.tsx';
|
||||||
import StatusContainer from 'soapbox/containers/status-container.tsx';
|
import StatusContainer from 'soapbox/containers/status-container.tsx';
|
||||||
import PlaceholderAccount from 'soapbox/features/placeholder/components/placeholder-account.tsx';
|
import PlaceholderAccount from 'soapbox/features/placeholder/components/placeholder-account.tsx';
|
||||||
|
@ -25,21 +29,21 @@ import PlaceholderStatus from 'soapbox/features/placeholder/components/placehold
|
||||||
import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts';
|
import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts';
|
||||||
import { useAppSelector } from 'soapbox/hooks/useAppSelector.ts';
|
import { useAppSelector } from 'soapbox/hooks/useAppSelector.ts';
|
||||||
import { useSuggestions } from 'soapbox/queries/suggestions.ts';
|
import { useSuggestions } from 'soapbox/queries/suggestions.ts';
|
||||||
|
import { SearchFilter } from 'soapbox/reducers/search.ts';
|
||||||
|
|
||||||
import type { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
import type { OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||||
import type { VirtuosoHandle } from 'react-virtuoso';
|
import type { VirtuosoHandle } from 'react-virtuoso';
|
||||||
// import type { SearchFilter } from 'soapbox/reducers/search.ts';
|
|
||||||
|
|
||||||
// const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
// accounts: { id: 'search_results.accounts', defaultMessage: 'People' },
|
accounts: { id: 'search_results.accounts', defaultMessage: 'People' },
|
||||||
// statuses: { id: 'search_results.statuses', defaultMessage: 'Posts' },
|
statuses: { id: 'search_results.statuses', defaultMessage: 'Posts' },
|
||||||
// hashtags: { id: 'search_results.hashtags', defaultMessage: 'Hashtags' },
|
hashtags: { id: 'search_results.hashtags', defaultMessage: 'Hashtags' },
|
||||||
// });
|
});
|
||||||
|
|
||||||
const SearchResults = () => {
|
const SearchResults = () => {
|
||||||
const node = useRef<VirtuosoHandle>(null);
|
const node = useRef<VirtuosoHandle>(null);
|
||||||
|
|
||||||
// const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const { data: suggestions } = useSuggestions();
|
const { data: suggestions } = useSuggestions();
|
||||||
|
@ -51,8 +55,8 @@ const SearchResults = () => {
|
||||||
const trends = useAppSelector((state) => state.trends.items);
|
const trends = useAppSelector((state) => state.trends.items);
|
||||||
const submitted = useAppSelector((state) => state.search.submitted);
|
const submitted = useAppSelector((state) => state.search.submitted);
|
||||||
const selectedFilter = useAppSelector((state) => state.search.filter);
|
const selectedFilter = useAppSelector((state) => state.search.filter);
|
||||||
// const filterByAccount = useAppSelector((state) => state.search.accountId || undefined);
|
const filterByAccount = useAppSelector((state) => state.search.accountId || undefined);
|
||||||
// const { account } = useAccount(filterByAccount);
|
const { account } = useAccount(filterByAccount);
|
||||||
|
|
||||||
const handleLoadMore = () => {
|
const handleLoadMore = () => {
|
||||||
if (results.accounts.size || results.statuses.size || results.hashtags.size) {
|
if (results.accounts.size || results.statuses.size || results.hashtags.size) {
|
||||||
|
@ -62,35 +66,27 @@ const SearchResults = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// const handleUnsetAccount = () => dispatch(setSearchAccount(null));
|
const handleUnsetAccount = () => dispatch(setSearchAccount(null));
|
||||||
|
|
||||||
// const selectFilter = (newActiveFilter: SearchFilter) => dispatch(setFilter(newActiveFilter));
|
const selectFilter = (newActiveFilter: SearchFilter) => dispatch(setFilter(newActiveFilter));
|
||||||
|
|
||||||
// const renderFilterBar = () => {
|
const renderFilterBar = () => {
|
||||||
// const items = [];
|
const items = [];
|
||||||
// items.push(
|
items.push(
|
||||||
// {
|
{
|
||||||
// text: intl.formatMessage(messages.statuses),
|
text: intl.formatMessage(messages.statuses),
|
||||||
// action: () => selectFilter('statuses'),
|
action: () => selectFilter('statuses'),
|
||||||
// name: 'statuses',
|
name: 'statuses',
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// text: intl.formatMessage(messages.accounts),
|
text: intl.formatMessage(messages.accounts),
|
||||||
// action: () => selectFilter('accounts'),
|
action: () => selectFilter('accounts'),
|
||||||
// name: 'accounts',
|
name: 'accounts',
|
||||||
// },
|
},
|
||||||
// );
|
);
|
||||||
|
|
||||||
// items.push(
|
return <Tabs items={items} activeItem={selectedFilter} />;
|
||||||
// {
|
};
|
||||||
// text: intl.formatMessage(messages.hashtags),
|
|
||||||
// action: () => selectFilter('hashtags'),
|
|
||||||
// name: 'hashtags',
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
|
|
||||||
// return <Tabs items={items} activeItem={selectedFilter} />;
|
|
||||||
// };
|
|
||||||
|
|
||||||
const getCurrentIndex = (id: string): number => {
|
const getCurrentIndex = (id: string): number => {
|
||||||
return resultsIds?.keySeq().findIndex(key => key === id);
|
return resultsIds?.keySeq().findIndex(key => key === id);
|
||||||
|
@ -219,7 +215,7 @@ const SearchResults = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* {filterByAccount ? (
|
{filterByAccount ? (
|
||||||
<HStack className='mb-4 border-b border-solid border-gray-200 px-2 pb-4 dark:border-gray-800' space={2}>
|
<HStack className='mb-4 border-b border-solid border-gray-200 px-2 pb-4 dark:border-gray-800' space={2}>
|
||||||
<IconButton iconClassName='h-5 w-5' src={xIcon} onClick={handleUnsetAccount} />
|
<IconButton iconClassName='h-5 w-5' src={xIcon} onClick={handleUnsetAccount} />
|
||||||
<Text truncate>
|
<Text truncate>
|
||||||
|
@ -232,7 +228,7 @@ const SearchResults = () => {
|
||||||
</HStack>
|
</HStack>
|
||||||
) : (
|
) : (
|
||||||
<div className='px-4'>{renderFilterBar()}</div>
|
<div className='px-4'>{renderFilterBar()}</div>
|
||||||
)} */}
|
)}
|
||||||
|
|
||||||
{noResultsMessage || (
|
{noResultsMessage || (
|
||||||
<ScrollableList
|
<ScrollableList
|
||||||
|
|
Ładowanie…
Reference in New Issue