using chats instead of notes for the chat

This commit is contained in:
Carter 2024-12-05 20:53:57 -06:00
parent 9ec1956687
commit cf45fcb98a
9 changed files with 201 additions and 284 deletions

View file

@ -17,6 +17,15 @@ export interface INoteAPIContext {
asRoot?: boolean,
as?: string
) => Promise<AxiosResponse<pond.ListNotesResponse>>;
listChats: (
limit: number,
offset: number,
order?: "asc" | "desc",
orderBy?: string,
search?: string,
asRoot?: boolean,
as?: string
) => Promise<AxiosResponse<pond.ListChatsResponse>>;
removeNote: (noteID: string) => Promise<AxiosResponse<pond.RemoveBinResponse>>;
}
@ -72,12 +81,38 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
);
};
const listChats = (
limit: number,
offset: number,
order?: "asc" | "desc",
orderBy?: string,
search?: string,
asRoot?: boolean,
as?: string
) => {
return get<pond.ListChatsResponse>(
pondURL(
"/chats" +
"?limit=" +
limit +
"&offset=" +
offset +
("&order=" + (order ? order : "asc")) +
("&by=" + (orderBy ? orderBy : "key")) +
(search ? "&search=" + search : "") +
(asRoot ? "&asRoot=" + asRoot.toString() : "") +
(as ? "&as=" + as : "")
)
);
};
return (
<NoteAPIContext.Provider
value={{
addNote,
getNote,
updateNote,
listChats,
listNotes,
removeNote
}}>