Skip to content

Commit

Permalink
🔨 Update withTotalCount type to enum 0 or 1
Browse files Browse the repository at this point in the history
  • Loading branch information
journey-ad committed Jun 20, 2024
1 parent f93250c commit 776f67d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/api/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
const SEARCH = gql`
query Search($queryInput: SearchQueryInput!) {
search(queryInput: $queryInput) {
keywords
torrents {
hash
name
Expand Down Expand Up @@ -54,7 +55,10 @@ const schema = z.object({
sortType: z.enum(SEARCH_PARAMS.sortType).default(DEFAULT_SORT_TYPE),
filterTime: z.enum(SEARCH_PARAMS.filterTime).default(DEFAULT_FILTER_TIME),
filterSize: z.enum(SEARCH_PARAMS.filterSize).default(DEFAULT_FILTER_SIZE),
withTotalCount: z.coerce.boolean().default(false),
withTotalCount: z
.enum(["0", "1"])
.transform((value) => value === "1")
.default("1"),
});

const handler = async (request: Request) => {
Expand Down
3 changes: 2 additions & 1 deletion app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ async function fetchData({
filterSize !== cachedSearchOption.filterSize;

if (isNewSearch) {
params.set("withTotalCount", "true");
cachedSearchOption = null; // Reset cachedSearchOption for new search
} else {
params.set("withTotalCount", "0");
}

try {
Expand Down

0 comments on commit 776f67d

Please sign in to comment.