Skip to content

Commit 12f4388

Browse files
committed
refactor: move Search related components to experimental folder add SearchSourceResultListEnd
1 parent 6a1baef commit 12f4388

25 files changed

+89
-45
lines changed

src/components/Channel/Channel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ import {
7878
} from './hooks/useChannelContainerClasses';
7979
import { findInMsgSetByDate, findInMsgSetById, makeAddNotifications } from './utils';
8080
import { getChannel } from '../../utils';
81+
import { useStateStore } from '../../store';
82+
import { CHANNEL_CONTAINER_ID } from './constants';
8183

8284
import type { MessageInputProps } from '../MessageInput';
8385

@@ -97,13 +99,11 @@ import {
9799
} from '../Attachment/attachment-sizing';
98100
import type { URLEnrichmentConfig } from '../MessageInput/hooks/useLinkPreviews';
99101
import { useThreadContext } from '../Threads';
100-
import { CHANNEL_CONTAINER_ID } from './constants';
101-
import {
102+
import type {
102103
DefaultSearchSources,
103104
SearchControllerState,
104105
SearchSource,
105-
} from '../Search/SearchController';
106-
import { useStateStore } from '../../store';
106+
} from '../../experimental/Search/SearchController';
107107

108108
const searchControllerStateSelector = <
109109
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,

src/components/ChannelList/ChannelList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ import { NullComponent } from '../UtilityComponents';
3232

3333
import { ChannelListContextProvider, useComponentContext } from '../../context';
3434
import { useChatContext } from '../../context/ChatContext';
35+
import { useStateStore } from '../../store';
3536

3637
import type { Channel, ChannelFilters, ChannelOptions, ChannelSort, Event } from 'stream-chat';
3738
import type { ChannelAvatarProps } from '../Avatar';
3839
import type { TranslationContextValue } from '../../context/TranslationContext';
3940
import type { DefaultStreamChatGenerics, PaginatorProps } from '../../types/types';
40-
import { useStateStore } from '../../store';
41-
import {
41+
import type {
4242
DefaultSearchSources,
4343
SearchControllerState,
4444
SearchSource,
45-
} from '../Search/SearchController';
45+
} from '../../experimental/Search/SearchController';
4646

4747
const DEFAULT_FILTERS = {};
4848
const DEFAULT_OPTIONS = {};

src/components/Chat/Chat.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
SearchController,
2323
SearchSource,
2424
UserSearchSource,
25-
} from '../Search/SearchController';
25+
} from '../../experimental/Search/SearchController';
2626

2727
export type ChatPropsForwardedToComponentContext<
2828
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -38,8 +38,9 @@ export type ChatPropsForwardedToComponentContext<
3838
| 'SearchSourceEmptyResults'
3939
| 'SearchSourceLoadingResults'
4040
| 'SearchSourceResultList'
41+
| 'SearchSourceResultListEnd'
4142
| 'SearchSourceResults'
42-
| 'SearchSourceResultsPresearch'
43+
| 'SearchResultsPresearch'
4344
>;
4445

4546
export type ChatProps<
@@ -112,6 +113,7 @@ export const Chat = <
112113
const searchController = useMemo(() => {
113114
if (customChannelSearchController) return customChannelSearchController;
114115
return new SearchController<StreamChatGenerics, SearchSources>({
116+
config: { keepSingleActiveSource: false },
115117
sources: ([
116118
new UserSearchSource<StreamChatGenerics>(client),
117119
new ChannelSearchSource<StreamChatGenerics>(client),
@@ -191,11 +193,12 @@ export const Chat = <
191193
SearchBar: props.SearchBar,
192194
SearchResults: props.SearchResults,
193195
SearchResultsHeader: props.SearchResultsHeader,
196+
SearchResultsPresearch: props.SearchResultsPresearch,
194197
SearchSourceEmptyResults: props.SearchSourceEmptyResults,
195198
SearchSourceLoadingResults: props.SearchSourceLoadingResults,
196199
SearchSourceResultList: props.SearchSourceResultList,
200+
SearchSourceResultListEnd: props.SearchSourceResultListEnd,
197201
SearchSourceResults: props.SearchSourceResults,
198-
SearchSourceResultsPresearch: props.SearchSourceResultsPresearch,
199202
SendButton: props.SendButton,
200203
StartRecordingAudioButton: props.StartRecordingAudioButton,
201204
ThreadHead: props.ThreadHead,
@@ -261,8 +264,9 @@ export const Chat = <
261264
props.SearchSourceEmptyResults,
262265
props.SearchSourceLoadingResults,
263266
props.SearchSourceResultList,
267+
props.SearchSourceResultListEnd,
264268
props.SearchSourceResults,
265-
props.SearchSourceResultsPresearch,
269+
props.SearchResultsPresearch,
266270
props.SendButton,
267271
props.StartRecordingAudioButton,
268272
props.ThreadHead,

src/components/Chat/hooks/useCreateChatContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { useMemo } from 'react';
22

33
import type { ChatContextValue } from '../../../context/ChatContext';
44
import type { DefaultStreamChatGenerics } from '../../../types/types';
5-
import type { DefaultSearchSources, SearchSource } from '../../Search/SearchController';
5+
import type {
6+
DefaultSearchSources,
7+
SearchSource,
8+
} from '../../../experimental/Search/SearchController';
69

710
export const useCreateChatContext = <
811
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,

src/components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export * from './Modal';
2929
export * from './Poll';
3030
export * from './Reactions';
3131
export * from './SafeAnchor';
32-
export * from './Search';
3332
export * from './Thread';
3433
export * from './Tooltip';
3534
export * from './TypingIndicator';

src/context/ChatContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
DefaultSearchSources,
1111
SearchController,
1212
SearchSource,
13-
} from '../components/Search/SearchController';
13+
} from '../experimental/Search/SearchController';
1414

1515
type CSSClasses =
1616
| 'chat'

src/context/ComponentContext.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ import {
3636
ReactionSelectorProps,
3737
ReactionsListProps,
3838
RecordingPermissionDeniedNotificationProps,
39-
SearchProps,
40-
SearchResultsPresearchProps,
41-
SearchSourceEmptyResultsProps,
42-
SearchSourceResultListProps,
4339
SendButtonProps,
4440
StartRecordingAudioButtonProps,
4541
SuggestionItemProps,
@@ -53,13 +49,21 @@ import {
5349
UnreadMessagesSeparatorProps,
5450
} from '../components';
5551

52+
import {
53+
SearchProps,
54+
SearchResultsPresearchProps,
55+
SearchSourceEmptyResultsProps,
56+
SearchSourceResultListEndProps,
57+
SearchSourceResultListProps,
58+
} from '../experimental';
59+
5660
import type {
5761
CustomTrigger,
5862
DefaultStreamChatGenerics,
5963
PropsWithChildrenOnly,
6064
UnknownType,
6165
} from '../types/types';
62-
import type { DefaultSearchSources, SearchSource } from '../components/Search/SearchController';
66+
import type { DefaultSearchSources, SearchSource } from '../experimental/Search/SearchController';
6367

6468
export type ComponentContextValue<
6569
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -189,6 +193,8 @@ export type ComponentContextValue<
189193
SearchSourceResultList?: React.ComponentType<
190194
SearchSourceResultListProps<StreamChatGenerics, SearchSources>
191195
>;
196+
/** Custom component to indicate the end of the last page for a searched source, defaults to and accepts same props as: [SearchSourceResultListEnd](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Search/SearchResults/SearchSourceResultListEnd.tsx) */
197+
SearchSourceResultListEnd?: React.ComponentType<SearchSourceResultListEndProps>;
192198
/** Custom UI component to display search results items for a given search source pane, defaults to and accepts same props as: [SearchSourceResults](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Search/SearchResults/SourceSearchResults.tsx) */
193199
SearchSourceResults?: React.ComponentType;
194200
/** Custom UI component for send button, defaults to and accepts same props as: [SendButton](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/icons.tsx) */

src/context/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from './ChannelActionContext';
22
export * from './ChannelListContext';
3-
export * from './SearchContext';
43
export * from './ChannelStateContext';
54
export * from './ChatContext';
65
export * from './ComponentContext';
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import React from 'react';
44
import { DefaultSearchSources, SearchControllerState, SearchSource } from './SearchController';
55
import { SearchBar as DefaultSearchBar } from './SearchBar/SearchBar';
66
import { SearchResults as DefaultSearchResults } from './SearchResults/SearchResults';
7-
import { SearchContextProvider, useChatContext, useComponentContext } from '../../context';
7+
import { SearchContextProvider } from './SearchContext';
8+
import { useChatContext, useComponentContext } from '../../context';
89
import { useStateStore } from '../../store';
910

1011
import type { DefaultStreamChatGenerics } from '../../types';

src/components/Search/SearchBar/SearchBar.tsx renamed to src/experimental/Search/SearchBar/SearchBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import clsx from 'clsx';
22
import React, { useCallback, useEffect } from 'react';
3-
import { useSearchContext, useTranslationContext } from '../../../context';
3+
import { useSearchContext } from '../SearchContext';
4+
import { useTranslationContext } from '../../../context';
45
import { useStateStore } from '../../../store';
56
import type { SearchControllerState } from '../SearchController';
67

0 commit comments

Comments
 (0)