Explore sorting (#15342)

* backend

* add type and params

* radio group in ui

* ensure search_type is cleared on reset
This commit is contained in:
Josh Hawkins
2024-12-04 09:54:10 -06:00
committed by GitHub
parent a5a7cd3107
commit c0ba98e26f
6 changed files with 241 additions and 15 deletions

View File

@@ -116,6 +116,7 @@ export default function Explore() {
is_submitted: searchSearchParams["is_submitted"],
has_clip: searchSearchParams["has_clip"],
event_id: searchSearchParams["event_id"],
sort: searchSearchParams["sort"],
limit:
Object.keys(searchSearchParams).length == 0 ? API_LIMIT : undefined,
timezone,
@@ -148,6 +149,7 @@ export default function Explore() {
is_submitted: searchSearchParams["is_submitted"],
has_clip: searchSearchParams["has_clip"],
event_id: searchSearchParams["event_id"],
sort: searchSearchParams["sort"],
timezone,
include_thumbnails: 0,
},
@@ -165,12 +167,17 @@ export default function Explore() {
const [url, params] = searchQuery;
// If it's not the first page, use the last item's start_time as the 'before' parameter
const isAscending = params.sort?.includes("date_asc");
if (pageIndex > 0 && previousPageData) {
const lastDate = previousPageData[previousPageData.length - 1].start_time;
return [
url,
{ ...params, before: lastDate.toString(), limit: API_LIMIT },
{
...params,
[isAscending ? "after" : "before"]: lastDate.toString(),
limit: API_LIMIT,
},
];
}