1.0.60
All checks were successful
Build and Release / build-and-release (push) Successful in 12m29s

This commit is contained in:
Bryan1029384756
2026-04-14 20:03:54 -05:00
parent b7a4cf4ce8
commit 965048f7d2
47 changed files with 2558 additions and 135 deletions

View File

@@ -245,18 +245,34 @@ export const categories = action({
return { categories: [] };
}
// Klipy's actual shape (verified against /api/v1/.../gifs/categories):
// { result: true, data: { locale: "en_US", categories: [
// { category: "hello", query: "hello", preview_url: "..." },
// ...
// ]}}
// Older / parallel paths (data.data[] from the search+trending
// endpoints, or a flat data[] array) are accepted as fallbacks so
// a future upstream change doesn't silently break the picker.
const json = (await response.json()) as any;
const items: any[] = Array.isArray(json?.data?.data)
? json.data.data
: Array.isArray(json?.data)
? json.data
: [];
const items: any[] = Array.isArray(json?.data?.categories)
? json.data.categories
: Array.isArray(json?.data?.data)
? json.data.data
: Array.isArray(json?.data)
? json.data
: [];
const categories: NormalizedCategory[] = items
.map((item) => ({
name: String(item?.name ?? item?.title ?? ""),
image: String(item?.image ?? item?.preview ?? ""),
query: String(item?.query ?? item?.search_term ?? item?.name ?? ""),
name: String(
item?.category ?? item?.name ?? item?.title ?? item?.query ?? "",
),
image: String(
item?.preview_url ?? item?.image ?? item?.preview ?? "",
),
query: String(
item?.query ?? item?.search_term ?? item?.category ?? item?.name ?? "",
),
}))
.filter((c) => !!c.query);