diff --git a/src/app/ItemSearchPage.js b/src/app/ItemSearchPage.js
index 47a21d9..e425888 100644
--- a/src/app/ItemSearchPage.js
+++ b/src/app/ItemSearchPage.js
@@ -132,16 +132,14 @@ function ItemSearchPageResults({ query: latestQuery, offset }) {
$zoneIds: [ID!]!
$offset: Int!
) {
- itemSearch(
+ itemSearch: itemSearchV2(
query: $query
itemKind: $itemKind
currentUserOwnsOrWants: $currentUserOwnsOrWants
zoneIds: $zoneIds
- offset: $offset
- limit: 30
) {
numTotalItems
- items {
+ items(offset: $offset, limit: 30) {
id
name
thumbnailUrl
@@ -163,6 +161,9 @@ function ItemSearchPageResults({ query: latestQuery, offset }) {
},
context: { sendAuth: true },
skip: searchQueryIsEmpty(query),
+ // This will give us the cached numTotalItems while we wait for the
+ // next item page!
+ returnPartialData: true,
}
);
@@ -170,23 +171,11 @@ function ItemSearchPageResults({ query: latestQuery, offset }) {
return null;
}
- if (loading) {
- return (
-
-
-
-
-
-
-
- );
- }
-
if (error) {
return ;
}
- if (data.itemSearch.items.length === 0) {
+ if (data?.itemSearch?.numTotalItems === 0) {
return (
We couldn't find any matching items{" "}
@@ -198,21 +187,33 @@ function ItemSearchPageResults({ query: latestQuery, offset }) {
);
}
+ const items = data?.itemSearch?.items || [];
+ const numTotalItems = data?.itemSearch?.numTotalItems || null;
+
return (
-
- {data.itemSearch.items.map((item) => (
-
-
-
- ))}
-
+ {items.length > 0 && (
+
+ {items.map((item) => (
+
+
+
+ ))}
+
+ )}
+ {loading && items.length === 0 && (
+
+
+
+ )}