(feat:attachments) clear after passing

This commit is contained in:
ManishMadan2882
2025-06-10 02:50:07 +05:30
parent ef35864e16
commit 68dc14c5a1
3 changed files with 20 additions and 3 deletions

View File

@@ -3,7 +3,10 @@ import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit';
import { getConversations } from '../preferences/preferenceApi';
import { setConversations } from '../preferences/preferenceSlice';
import store from '../store';
import { selectCompletedAttachments } from '../upload/uploadSlice';
import {
selectCompletedAttachments,
clearAttachments,
} from '../upload/uploadSlice';
import {
handleFetchAnswer,
handleFetchAnswerSteaming,
@@ -41,6 +44,11 @@ export const fetchAnswer = createAsyncThunk<
const attachmentIds = selectCompletedAttachments(state)
.filter((a) => a.id)
.map((a) => a.id) as string[];
if (attachmentIds.length > 0) {
dispatch(clearAttachments());
}
const currentConversationId = state.conversation.conversationId;
const conversationIdToSend = isPreview ? null : currentConversationId;
const save_conversation = isPreview ? false : true;

View File

@@ -7,7 +7,10 @@ import {
handleFetchSharedAnswer,
handleFetchSharedAnswerStreaming,
} from './conversationHandlers';
import { selectCompletedAttachments } from '../upload/uploadSlice';
import {
selectCompletedAttachments,
clearAttachments,
} from '../upload/uploadSlice';
const API_STREAMING = import.meta.env.VITE_API_STREAMING === 'true';
interface SharedConversationsType {
@@ -34,6 +37,10 @@ export const fetchSharedAnswer = createAsyncThunk<Answer, { question: string }>(
.filter((a) => a.id)
.map((a) => a.id) as string[];
if (attachmentIds.length > 0) {
dispatch(clearAttachments());
}
if (state.preference && state.sharedConversation.apiKey) {
if (API_STREAMING) {
await handleFetchSharedAnswerStreaming(

View File

@@ -48,7 +48,9 @@ export const uploadSlice = createSlice({
);
},
clearAttachments: (state) => {
state.attachments = [];
state.attachments = state.attachments.filter(
(att) => att.status === 'uploading' || att.status === 'processing',
);
},
},
});