From 001b25c92aa2e37835a289677c8cea9357ad6150 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Fri, 28 Mar 2025 10:08:22 +0530 Subject: [PATCH] fix: Reset recorder and attachments when switching chats (#11174) # Pull Request Template ## Description This PR will reset the recorder and clear attachments when switching chats. It ensures that any ongoing recordings or attached files do not persist across different conversations Fixes https://linear.app/chatwoot/issue/CW-4157/recorded-audio-is-being-preserved-between-conversations https://github.com/chatwoot/chatwoot/issues/11136 ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? ### Loom video https://www.loom.com/share/6d6361650794426497467d6de1b4900d?sid=d856c540-1032-4ea2-8765-8704b76e8e1d ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --- .../dashboard/components/widgets/conversation/ReplyBox.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue index d9b1de5e9..c42b678fd 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue @@ -420,6 +420,7 @@ export default { if (conversationId !== oldConversationId) { this.setToDraft(oldConversationId, this.replyType); this.getFromDraft(); + this.resetRecorderAndClearAttachments(); } }, message(updatedMessage) { @@ -529,6 +530,12 @@ export default { ); } }, + resetRecorderAndClearAttachments() { + // Reset audio recorder UI state + this.resetAudioRecorderInput(); + // Reset attached files + this.attachedFiles = []; + }, saveDraft(conversationId, replyType) { if (this.message || this.message === '') { const key = `draft-${conversationId}-${replyType}`;