Dedupe attachments by file name, but allow any number of pasted images.
Previously, the code simply deduped attachments on file name, using the internal name `image.png` for any pasted image. This effectively made it possible to paste only a single image into a message. Now, we ignore files called `image.png` when deduping. Deduping on file name is flawed anyway, because: 1. It's trivial to post multiple identical attachments, so long as each of them has a different file name. 2. It's **not** possible to post different attachments if they happen to have the same base file name (i.e. after the directory component is removed). So, we're actually getting both false positives and false negatives here. Fixes #2345, but introduces a new problem: When deleting a pasted attachment from a list of such attachments prior to sending, **all** pasted attachments are removed, presumably due to their all having the same internal file name. It may be better not to dedupe attachments at all, rather than use the crude mechanism of the file name. In that case, the following code would suffice: ``` - const uniqAttachments = _.uniqBy(allAttachments, m => m.fileName); - state.stagedAttachments[conversationKey] = uniqAttachments; + state.stagedAttachments[conversationKey] = allAttachments; ```pull/2681/head
parent
2710ea9134
commit
34a8c1a8a5
Loading…
Reference in New Issue