cozy-search
Version:
UI components about search bar and IA assistant
71 lines (70 loc) • 2.59 kB
TypeScript
export default useFetchConversations;
/**
* We use `client.query` manually instead of the `useQuery` hook from cozy-client
* because `useQuery` currently drops the `included` array from its output state.
* Without `included`, we cannot easily map the `assistant` relationship to each conversation.
*
* For more details on the cozy-client issue, see:
* https://github.com/linagora/cozy-client/issues/1083
*/
export type Assistant = {
_id: string;
name: string;
icon?: string | undefined;
};
/**
* We use `client.query` manually instead of the `useQuery` hook from cozy-client
* because `useQuery` currently drops the `included` array from its output state.
* Without `included`, we cannot easily map the `assistant` relationship to each conversation.
*
* For more details on the cozy-client issue, see:
* https://github.com/linagora/cozy-client/issues/1083
*/
export type ConversationWithAssistant = {
_id: string;
messages: any[];
/**
* - The assistant object bolted on from the query's `included` relationships, or the DEFAULT_ASSISTANT fallback.
*/
assistant: Assistant;
};
/**
* We use `client.query` manually instead of the `useQuery` hook from cozy-client
* because `useQuery` currently drops the `included` array from its output state.
* Without `included`, we cannot easily map the `assistant` relationship to each conversation.
*
* For more details on the cozy-client issue, see:
* https://github.com/linagora/cozy-client/issues/1083
*
* @typedef {Object} Assistant
* @property {string} _id
* @property {string} name
* @property {string} [icon]
*
* @typedef {Object} ConversationWithAssistant
* @property {string} _id
* @property {Array} messages
* @property {Assistant} assistant - The assistant object bolted on from the query's `included` relationships, or the DEFAULT_ASSISTANT fallback.
*
* @param {Object} [props={}]
* @param {Object} [props.query={}] - Optional query filters to pass to `where()`
*
* @returns {{
* conversations: ConversationWithAssistant[],
* hasMore: boolean,
* bookmark: string|null,
* isLoading: boolean,
* fetchMore: function(): Promise<void>,
* fetchConversations: function(string|null, Object): Promise<void>
* }}
*/
declare function useFetchConversations({ query }?: {
query?: Object | undefined;
} | undefined): {
conversations: ConversationWithAssistant[];
hasMore: boolean;
bookmark: string | null;
isLoading: boolean;
fetchMore: () => Promise<void>;
fetchConversations: (arg0: string | null, arg1: Object) => Promise<void>;
};