Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Encrypted files cannot be downloaded repeatedly from the Room Files menu

Open Sakshamlabs opened this issue 2 weeks ago • 3 comments

Description

Downloading an encrypted file from the Room Files menu works for the first request, but subsequent download requests can fail to trigger the download.

The response listener is registered when the FileItemMenu component mounts and uses a one-time listener. Once the first download response is received, that listener is consumed. If the component remains mounted, later requests reuse the same ID, but there is no longer an active listener waiting for the response.

Steps to reproduce

  1. Open a room and navigate to the Files section in the contextual bar.
  2. Select an encrypted file.
  3. Open its menu and click Download.
  4. After the first download completes, open the menu again.
  5. Click Download again.

Expected behaviour

Every download request should be handled independently, allowing the same encrypted file to be downloaded multiple times without reopening the room or remounting the component.

Actual behaviour

After the first response consumes the one-time listener, subsequent responses may not trigger the download.

Suggested direction

Register a response listener for each download request and use a unique request ID to match each response to its corresponding request.

Sakshamlabs avatar Nov 12 '26 11:11 Sakshamlabs

Hi, I'd like to work on this. FileItemMenu registers ee.once(uid) a single time in a useEffect and reuses the useId value for every request, so I'd register the listener inside the Download click handler with a fresh id per request (useDownloadFromServiceWorker has the same pattern, so I'd fix it there too).

schizophrenicmaniac avatar Nov 12 '26 12:11 schizophrenicmaniac

hello @schizophrenicmaniac i already prepared pr with the implementation and raising it .

Sakshamlabs avatar Nov 12 '26 12:11 Sakshamlabs

Regarding useDownloadFromServiceWorker, that's a good point. I will take a closer look at its implementation to check whether the same issue applies there as well.

Sakshamlabs avatar Nov 12 '26 12:11 Sakshamlabs