Spaces:
Running
Running
Update components/ai/ChatPanel.tsx
Browse files
components/ai/ChatPanel.tsx
CHANGED
|
@@ -179,6 +179,9 @@ export const ChatPanel: React.FC<ChatPanelProps> = ({ currentUser }) => {
|
|
| 179 |
|
| 180 |
setIsChatProcessing(true);
|
| 181 |
|
|
|
|
|
|
|
|
|
|
| 182 |
try {
|
| 183 |
// Process Images to Base64 first to update UI correctly
|
| 184 |
const base64Images = await Promise.all(currentImages.map(f => compressImage(f)));
|
|
@@ -192,7 +195,7 @@ export const ChatPanel: React.FC<ChatPanelProps> = ({ currentUser }) => {
|
|
| 192 |
images: base64Images,
|
| 193 |
timestamp: Date.now()
|
| 194 |
};
|
| 195 |
-
|
| 196 |
const newAiMsg: AIChatMessage = { id: newAiMsgId, role: 'model', text: '', timestamp: Date.now() };
|
| 197 |
|
| 198 |
setMessages(prev => [...prev, newUserMsg, newAiMsg]);
|
|
|
|
| 179 |
|
| 180 |
setIsChatProcessing(true);
|
| 181 |
|
| 182 |
+
// Define ID outside try block so it is available in catch block
|
| 183 |
+
const newAiMsgId = (Date.now() + 1).toString();
|
| 184 |
+
|
| 185 |
try {
|
| 186 |
// Process Images to Base64 first to update UI correctly
|
| 187 |
const base64Images = await Promise.all(currentImages.map(f => compressImage(f)));
|
|
|
|
| 195 |
images: base64Images,
|
| 196 |
timestamp: Date.now()
|
| 197 |
};
|
| 198 |
+
|
| 199 |
const newAiMsg: AIChatMessage = { id: newAiMsgId, role: 'model', text: '', timestamp: Date.now() };
|
| 200 |
|
| 201 |
setMessages(prev => [...prev, newUserMsg, newAiMsg]);
|