Update chat.js
Browse files- static/js/ui/chat.js +20 -15
static/js/ui/chat.js
CHANGED
|
@@ -361,21 +361,26 @@ export async function addMessageToUI(message, index, options = {}, existingEleme
|
|
| 361 |
|
| 362 |
let finalElement = existingElement;
|
| 363 |
|
| 364 |
-
// *** منطق
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
const
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
}
|
| 380 |
}
|
| 381 |
|
|
|
|
| 361 |
|
| 362 |
let finalElement = existingElement;
|
| 363 |
|
| 364 |
+
// *** منطق جدید و دقیق برای پاکسازی دکمههای پیامهای قبلی ***
|
| 365 |
+
if (!existingElement) {
|
| 366 |
+
// 1. حذف دکمه ویرایش از آخرین پیام کاربر (اگر وجود دارد)
|
| 367 |
+
const lastUserMsg = dom.chatWindow.querySelector('.message-entry.user:last-of-type');
|
| 368 |
+
if (lastUserMsg) {
|
| 369 |
+
const idx = parseInt(lastUserMsg.dataset.index, 10);
|
| 370 |
+
const chat = state.getActiveChat();
|
| 371 |
+
if(chat && chat.messages[idx]) {
|
| 372 |
+
updateMessageActions(lastUserMsg, chat.messages[idx], false, false);
|
| 373 |
+
}
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
// 2. حذف دکمه تلاش مجدد از آخرین پیام مدل (اگر وجود دارد)
|
| 377 |
+
const lastModelMsg = dom.chatWindow.querySelector('.message-entry.model:last-of-type');
|
| 378 |
+
if (lastModelMsg) {
|
| 379 |
+
const idx = parseInt(lastModelMsg.dataset.index, 10);
|
| 380 |
+
const chat = state.getActiveChat();
|
| 381 |
+
if(chat && chat.messages[idx]) {
|
| 382 |
+
updateMessageActions(lastModelMsg, chat.messages[idx], false, false);
|
| 383 |
+
}
|
| 384 |
}
|
| 385 |
}
|
| 386 |
|