refactor and optimize search, add RQ for search

This commit is contained in:
Daniel D Orlando 2023-04-06 05:47:37 -07:00
parent 3d0bfaef51
commit 61cb2858bb
13 changed files with 71 additions and 102 deletions

View file

@ -49,35 +49,14 @@ export function getSearchEnabled(): Promise<boolean> {
return request.get(endpoints.searchEnabled());
}
export function getSearchResults(q: string, pageNumber: string): Promise<t.TSearchResults> {
return request.get(endpoints.search(q, pageNumber));
}
export function getUser(): Promise<t.TUser> {
return request.get(endpoints.user());
}
type TSearchFetcherProps = {
pre: () => void,
q: string,
pageNumber: string,
callback: (data: any) => void
};
export const searchConversations = async({ q, pageNumber, callback }: TSearchFetcherProps) => {
return request.get(endpoints.search(q, pageNumber)).then(({ data }) => {
callback(data);
});
export const searchConversations = async(q: string, pageNumber: string): Promise<t.TSearchResults> => {
return request.get(endpoints.search(q, pageNumber));
}
export const searchFetcher = async ({ pre, q, pageNumber, callback }: TSearchFetcherProps) => {
pre();
//@ts-ignore
const { data } = await request.get(endpoints.search(q, pageNumber));
console.log('search data', data);
callback(data);
};
export const getAIEndpoints = () => {
return request.get(endpoints.aiEndpoints());
}