Shun Miyazawa 1 год назад
Родитель
Сommit
8f818cd7c1
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      apps/app/src/features/openai/client/stores/thread.tsx

+ 4 - 2
apps/app/src/features/openai/client/stores/thread.tsx

@@ -6,8 +6,10 @@ import { apiv3Get } from '~/client/util/apiv3-client';
 
 import type { IThreadRelationHasId } from '../../interfaces/thread-relation';
 
+const getKey = (aiAssistantId: string) => [`openai/threads/${aiAssistantId}`];
+
 export const useSWRxThreads = (aiAssistantId: string): SWRResponse<IThreadRelationHasId[], Error> => {
-  const key = [`openai/threads/${aiAssistantId}`];
+  const key = getKey(aiAssistantId);
   return useSWRImmutable<IThreadRelationHasId[]>(
     key,
     ([endpoint]) => apiv3Get(endpoint).then(response => response.data.threads),
@@ -16,7 +18,7 @@ export const useSWRxThreads = (aiAssistantId: string): SWRResponse<IThreadRelati
 
 
 export const useSWRMUTxThreads = (aiAssistantId: string): SWRMutationResponse<IThreadRelationHasId[], Error> => {
-  const key = [`openai/threads/${aiAssistantId}`];
+  const key = getKey(aiAssistantId);
   return useSWRMutation(
     key,
     ([endpoint]) => apiv3Get(endpoint).then(response => response.data.threads),