|
|
@@ -1,12 +1,11 @@
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
|
|
-import { getIdStringForRef, isPopulated } from '@growi/core';
|
|
|
+import { getIdStringForRef } from '@growi/core';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import InfiniteScroll from '~/client/components/InfiniteScroll';
|
|
|
import { toastError, toastSuccess } from '~/client/util/toastr';
|
|
|
import { useSWRINFxRecentThreads } from '~/features/openai/client/stores/thread';
|
|
|
-import type { IThreadRelationHasId } from '~/features/openai/interfaces/thread-relation';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
import { deleteThread } from '../../../services/thread';
|
|
|
@@ -23,13 +22,6 @@ export const ThreadList: React.FC = () => {
|
|
|
const isEmpty = data?.[0]?.paginateResult.totalDocs === 0;
|
|
|
const isReachingEnd = isEmpty || (data != null && (data[data.length - 1].paginateResult.hasNextPage === false));
|
|
|
|
|
|
- const openChatHandler = useCallback((threadData: IThreadRelationHasId) => {
|
|
|
- const aiAssistant = threadData.aiAssistant;
|
|
|
- if (isPopulated(aiAssistant)) {
|
|
|
- openChat({ ...aiAssistant, _id: getIdStringForRef(aiAssistant._id) }, threadData);
|
|
|
- }
|
|
|
- }, [openChat]);
|
|
|
-
|
|
|
const deleteThreadHandler = useCallback(async(aiAssistantId: string, threadRelationId: string) => {
|
|
|
try {
|
|
|
await deleteThread({ aiAssistantId, threadRelationId });
|
|
|
@@ -54,7 +46,7 @@ export const ThreadList: React.FC = () => {
|
|
|
className="list-group-item list-group-item-action border-0 d-flex align-items-center rounded-1"
|
|
|
onClick={(e) => {
|
|
|
e.stopPropagation();
|
|
|
- openChatHandler(thread);
|
|
|
+ openChat(thread.aiAssistant, thread);
|
|
|
}}
|
|
|
>
|
|
|
<div>
|