chatwoot/app/javascript
Sivin Varghese 6b767dbe94
fix: Duplicate attachments when navigating back to a conversation (#11472)
# Pull Request Template

## Description

Fixes
[CW-4330](https://linear.app/chatwoot/issue/CW-4330/bug-attachments-in-gallery-view-gets-duplicated-when-you-navigate-back)

**Cause**
When navigating back to a previously viewed conversation, attachments
were being duplicated in the Gallery View. This occurred because the
`SET_ALL_ATTACHMENTS` mutation was appending new attachments to existing
ones `(attachments.push(...data))` instead of replacing them. Each time
a user returned to a conversation, the attachment list would grow,
showing duplicate images.

**Solution**
Updated the `SET_ALL_ATTACHMENTS` mutation to replace the entire
attachments array instead of appending to it. This change ensures
attachments are cleared before adding new ones when returning to a
previously viewed conversation, preventing duplicates.

## 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/b2472c07e95843f6879724b19ef89311?sid=eed42238-b4bc-4dbe-8ede-a25a13b4610d

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [ ] 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
2025-05-14 15:40:11 -07:00
..
dashboard fix: Duplicate attachments when navigating back to a conversation (#11472) 2025-05-14 15:40:11 -07:00
design-system feat: Add histoire for component playground (#10256) 2024-10-09 22:10:53 -07:00
entrypoints feat: handle rails turbo morphing (#11422) 2025-05-07 10:22:08 +05:30
portal chore: Make the table of contents in help center sticky (#11448) 2025-05-09 08:44:44 +05:30
sdk feat: handle rails turbo morphing (#11422) 2025-05-07 10:22:08 +05:30
shared fix: Update flag from countries.js (#11401) 2025-05-01 09:03:36 -07:00
superadmin_pages chore: fix circleci on vite build (#10214) 2024-10-07 15:27:41 +05:30
survey feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
v3 feat: allow auto resolve waiting option (#11436) 2025-05-08 12:52:17 +05:30
widget feat: widget opened and closed events (#11240) 2025-04-24 17:01:39 +05:30
histoire.setup.ts feat: Add compose conversation components (#10457) 2024-12-05 16:31:47 -08:00