chore(frontend): Disable /feedback/conversation/{conversationId}/batch for V1 conversations (#11668)

This commit is contained in:
sp.wack 2025-11-07 17:50:09 +04:00 committed by GitHub
parent ad75cd05d8
commit bfe60d3bbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import ConversationService from "#/api/conversation-service/conversation-service
import { useConversationId } from "#/hooks/use-conversation-id";
import { useConfig } from "#/hooks/query/use-config";
import { useRuntimeIsReady } from "#/hooks/use-runtime-is-ready";
import { useActiveConversation } from "#/hooks/query/use-active-conversation";
export interface BatchFeedbackData {
exists: boolean;
@ -25,13 +26,20 @@ export const getFeedbackExistsQueryKey = (
export const useBatchFeedback = () => {
const { conversationId } = useConversationId();
const { data: config } = useConfig();
const { data: conversation } = useActiveConversation();
const queryClient = useQueryClient();
const runtimeIsReady = useRuntimeIsReady();
const isV1Conversation = conversation?.conversation_version === "V1";
const query = useQuery({
queryKey: getFeedbackQueryKey(conversationId),
queryFn: () => ConversationService.getBatchFeedback(conversationId!),
enabled: runtimeIsReady && !!conversationId && config?.APP_MODE === "saas",
enabled:
runtimeIsReady &&
!!conversationId &&
config?.APP_MODE === "saas" &&
!isV1Conversation,
staleTime: 1000 * 60 * 5, // 5 minutes
gcTime: 1000 * 60 * 15, // 15 minutes
});

View File

@ -1,6 +1,7 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useConversationId } from "#/hooks/use-conversation-id";
import { useConfig } from "#/hooks/query/use-config";
import { useActiveConversation } from "#/hooks/query/use-active-conversation";
import { BatchFeedbackData, getFeedbackQueryKey } from "./use-batch-feedback";
export type FeedbackData = BatchFeedbackData;
@ -9,6 +10,9 @@ export const useFeedbackExists = (eventId?: number) => {
const queryClient = useQueryClient();
const { conversationId } = useConversationId();
const { data: config } = useConfig();
const { data: conversation } = useActiveConversation();
const isV1Conversation = conversation?.conversation_version === "V1";
return useQuery<FeedbackData>({
queryKey: [...getFeedbackQueryKey(conversationId), eventId],
@ -22,7 +26,11 @@ export const useFeedbackExists = (eventId?: number) => {
return batchData?.[eventId.toString()] ?? { exists: false };
},
enabled: !!eventId && !!conversationId && config?.APP_MODE === "saas",
enabled:
!!eventId &&
!!conversationId &&
config?.APP_MODE === "saas" &&
!isV1Conversation,
staleTime: 1000 * 60 * 5, // 5 minutes
gcTime: 1000 * 60 * 15, // 15 minutes
});