Skip to content

Commit

Permalink
fix live query
Browse files Browse the repository at this point in the history
  • Loading branch information
sphinxrave committed Oct 18, 2023
1 parent 48a503c commit 438e92c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 0 additions & 2 deletions packages/react/src/lib/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function toStr(x: unknown): string {

const stringify = (obj: object) => {
return (new URLSearchParams(Object.entries(obj).flatMap(([k, v]) => Array.isArray(v) ? v.map(x => ([k, toStr(x)])) : [[k, typeof v === "object" ? JSON.stringify(v) : String(v)]]))).toString()


}


Expand Down
9 changes: 7 additions & 2 deletions packages/react/src/services/live.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface UseLiveParams {
lang?: string[];
type?: VideoType[];
topic?: string;
include?:VideoIncludeParam[];
include?: VideoIncludeParam[];
org?: string;
mentioned_channel_id?: string;
sort?: string;
Expand All @@ -20,6 +20,11 @@ interface UseLiveParams {
id?: string;
}

function listToString(list: string[] | undefined) {
if (!list) return undefined
return list.join(",");
}

export function useLive(
params?: UseLiveParams,
config?: UseQueryOptions<Live[], AxiosError>,
Expand All @@ -28,7 +33,7 @@ export function useLive(

return useQuery<Live[], AxiosError>(
["live", params],
async () => (await client<Live[]>("/api/v2/live", { params })),
async () => (await client<Live[]>("/api/v2/live", { params: { ...params, type: listToString(params?.type), lang: listToString(params?.lang), include: listToString(params?.include) } })),
config,
);
}

0 comments on commit 438e92c

Please sign in to comment.