Skip to content

Commit 6a1baef

Browse files
committed
feat: remove SearchSourceResultsError component and export all search components and types
1 parent ddeaca7 commit 6a1baef

File tree

6 files changed

+19
-33
lines changed

6 files changed

+19
-33
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './SearchBar';
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { SearchSourceEmptyResults as DefaultSearchSourceEmptyResults } from './SearchSourceEmptyResults';
3-
import { SearchSourceResultsError as DefaultSearchSourceResultsError } from './SearchSourceResultsError';
43
import { SearchSourceResultList as DefaultSearchSourceResultList } from './SearchSourceResultList';
54
import { useComponentContext } from '../../../context';
65
import { useStateStore } from '../../../store';
@@ -10,7 +9,6 @@ import type { DefaultStreamChatGenerics } from '../../../types';
109
const searchSourceStateSelector = (nextValue: SearchSourceState) => ({
1110
isLoading: nextValue.isLoading,
1211
items: nextValue.items,
13-
lastQueryError: nextValue.lastQueryError,
1412
});
1513

1614
export type SearchSourceResultsProps = { searchSource: SearchSource };
@@ -22,22 +20,13 @@ export const SearchSourceResults = <
2220
}: SearchSourceResultsProps) => {
2321
const {
2422
SearchSourceEmptyResults = DefaultSearchSourceEmptyResults,
25-
SearchSourceResultsError = DefaultSearchSourceResultsError,
2623
SearchSourceResultList = DefaultSearchSourceResultList,
2724
} = useComponentContext<StreamChatGenerics, NonNullable<unknown>, SearchSources>();
28-
const { isLoading, items, lastQueryError } = useStateStore(
29-
searchSource.state,
30-
searchSourceStateSelector,
31-
);
25+
const { isLoading, items } = useStateStore(searchSource.state, searchSourceStateSelector);
3226

33-
return !items && !isLoading ? null : (
34-
<>
35-
{lastQueryError && <SearchSourceResultsError error={lastQueryError} />}
36-
{items?.length || isLoading ? (
37-
<SearchSourceResultList isLoading={isLoading} items={items} searchSource={searchSource} />
38-
) : (
39-
<SearchSourceEmptyResults searchSource={searchSource} />
40-
)}
41-
</>
27+
return !items && !isLoading ? null : items?.length || isLoading ? (
28+
<SearchSourceResultList isLoading={isLoading} items={items} searchSource={searchSource} />
29+
) : (
30+
<SearchSourceEmptyResults searchSource={searchSource} />
4231
);
4332
};

src/components/Search/SearchResults/SearchSourceResultsError.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export * from './SearchResultItem';
2+
export * from './SearchResults';
3+
export * from './SearchResultsHeader';
4+
export * from './SearchResultsPresearch';
5+
export * from './SearchSourceEmptyResults';
6+
export * from './SearchSourceLoadingResults';
7+
export * from './SearchSourceResultList';
8+
export * from './SearchSourceResults';

src/components/Search/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export * from './Search';
2+
export * from './SearchBar';
3+
export * from './SearchResults';

src/context/ComponentContext.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ import {
3737
ReactionsListProps,
3838
RecordingPermissionDeniedNotificationProps,
3939
SearchProps,
40+
SearchResultsPresearchProps,
41+
SearchSourceEmptyResultsProps,
42+
SearchSourceResultListProps,
4043
SendButtonProps,
4144
StartRecordingAudioButtonProps,
4245
SuggestionItemProps,
@@ -57,10 +60,6 @@ import type {
5760
UnknownType,
5861
} from '../types/types';
5962
import type { DefaultSearchSources, SearchSource } from '../components/Search/SearchController';
60-
import { SearchSourceEmptyResultsProps } from '../components/Search/SearchResults/SearchSourceEmptyResults';
61-
import { SearchSourceResultListProps } from '../components/Search/SearchResults/SearchSourceResultList';
62-
import { SearchResultsPresearchProps } from '../components/Search/SearchResults/SearchResultsPresearch';
63-
import { SearchSourceResultsErrorProps } from '../components/Search/SearchResults/SearchSourceResultsError';
6463

6564
export type ComponentContextValue<
6665
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -192,8 +191,6 @@ export type ComponentContextValue<
192191
>;
193192
/** 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) */
194193
SearchSourceResults?: React.ComponentType;
195-
/** Custom UI component to display error produced by search query, defaults to and accepts same props as: [SearchSourceResultsError](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Search/SearchResults/SearchSourceResultsError.tsx) */
196-
SearchSourceResultsError?: React.ComponentType<SearchSourceResultsErrorProps>;
197194
/** 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) */
198195
SendButton?: React.ComponentType<SendButtonProps<StreamChatGenerics>>;
199196
/** Custom UI component button for initiating audio recording, defaults to and accepts same props as: [StartRecordingAudioButton](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MediaRecorder/AudioRecorder/AudioRecordingButtons.tsx) */

0 commit comments

Comments
 (0)