Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/expo/components/CategoriesFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function CategoriesFilter({
<View
// biome-ignore lint/suspicious/noArrayIndexKey: just for skeleton
key={i}
className="h-8 w-20 rounded-full mr-2 bg-neutral-300 dark:bg-neutral-600 animate-pulse"
className="h-8 w-20 rounded-full mr-2 bg-neutral-300 dark:bg-neutral-600"
/>
))
: data.map(renderFilterChip)}
Expand Down
45 changes: 25 additions & 20 deletions apps/expo/features/catalog/screens/CatalogItemsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function CatalogItemsScreen() {
const [activeFilter, setActiveFilter] = useState<'All' | string>('All');
const [debouncedSearchValue] = useDebounce(searchValue, 400);

const isSearching = debouncedSearchValue.length > 0;
const isSearching = searchValue.trim().length > 0;
const trimmedQuery = debouncedSearchValue.trim();
const isQueryReady = trimmedQuery.length > 0;

const {
data: categories,
Expand All @@ -59,10 +61,9 @@ function CatalogItemsScreen() {
const {
data: vectorResult,
isLoading: isVectorLoading,
isFetching: _isVectorFetching,
error: vectorError,
} = useVectorSearch({ query: debouncedSearchValue, limit: 10 });
const searchResults = vectorResult?.items;
} = useVectorSearch({ query: trimmedQuery, limit: 10 });
const searchResults: CatalogItem[] = vectorResult?.items ?? [];
Comment thread
Isthisanmol marked this conversation as resolved.

const paginatedItems: CatalogItem[] = (
paginatedData?.pages.flatMap((page) => page.items) ?? []
Expand Down Expand Up @@ -102,7 +103,7 @@ function CatalogItemsScreen() {
content: (
<View style={{ flex: 1, backgroundColor: colors.background }}>
{isSearching ? (
isVectorLoading ? (
isVectorLoading || !isQueryReady ? (
<View className="flex-1 items-center justify-center p-6">
<ActivityIndicator className="text-primary" size="large" />
</View>
Expand Down Expand Up @@ -161,14 +162,16 @@ function CatalogItemsScreen() {
}}
/>

<CategoriesFilter
data={categories}
onFilter={setActiveFilter}
activeFilter={activeFilter}
error={categoriesError}
retry={refetchCategories}
className="px-4 py-2"
/>
{!isSearching && (
<CategoriesFilter
data={categories}
onFilter={setActiveFilter}
activeFilter={activeFilter}
error={categoriesError}
retry={refetchCategories}
className="px-4 py-2"
/>
)}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

<FlatList
key={activeFilter}
Expand Down Expand Up @@ -197,14 +200,16 @@ function CatalogItemsScreen() {
</View>
}
ListHeaderComponent={
<View className="mb-4">
<View className="flex-row items-center justify-between">
<Text className="text-muted-foreground">{totalItemsText}</Text>
!isSearching ? (
<View className="mb-4">
<View className="flex-row items-center justify-between">
<Text className="text-muted-foreground">{totalItemsText}</Text>
</View>
{paginatedItems.length > 0 && (
<Text className="mt-1 text-xs text-muted-foreground">{showingText}</Text>
)}
</View>
{paginatedItems.length > 0 && (
<Text className="mt-1 text-xs text-muted-foreground">{showingText}</Text>
)}
</View>
) : null
}
ListEmptyComponent={
<View className="flex-1 items-center justify-center p-8">
Expand Down