| 1569 | await eventSource.emit(event_types.MESSAGE_DELETED, chat.length); | 1569 | await eventSource.emit(event_types.MESSAGE_DELETED, chat.length); |
| 1570 | } | 1570 | } |
| 1571 | | 1571 | |
| 1572 | export async function reloadCurrentChat() { | 1572 | export const reloadChatMutex = new SimpleMutex(reloadCurrentChatUnsafe); |
| | 1573 | export const reloadCurrentChat = reloadChatMutex.update.bind(reloadChatMutex); |
| | 1574 | |
| | 1575 | /** |
| | 1576 | * Reloads the current chat unsafely, without mutex protection. |
| | 1577 | * Use `reloadCurrentChat` instead to ensure thread safety. |
| | 1578 | * @returns {Promise<void>} A promise that resolves when the chat is reloaded. |
| | 1579 | */ |
| | 1580 | export async function reloadCurrentChatUnsafe() { |
| 1573 | preserveNeutralChat(); | 1581 | preserveNeutralChat(); |
| 1574 | await clearChat(); | 1582 | await clearChat(); |
| 1575 | chat.length = 0; | 1583 | chat.length = 0; |