feature: Implement Download Caching for Chat Attachments

Aperta
#6,730 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@JASIM0021 ci sta già lavorando.

Dal 19/11/2025.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
react-native, typescript
Ambito
mobile

Direzione di ricerca

Individua il punto di ingresso fileDownload e leggi le implementazioni esistenti di getMediaCache e downloadMediaFile, quindi traccia il modo in cui gli allegati della chat invocano i download. Il lavoro è completato quando un allegato scaricato in precedenza viene servito dalla cache locale agli accessi successivi, mentre gli allegati non memorizzati nella cache continuano a essere scaricati normalmente; verifica il comportamento tramite il flusso esistente degli allegati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🎉 feature
Feature Description
  • Implement a caching system for chat attachment downloads that stores files locally after first download, allowing subsequent access to use cached versions instead of re-downloading. This will significantly improve user experience by reducing download times, saving data usage, and eliminating redundant downloads for the same file.

poc:-

https://github.com/user-attachments/assets/4e5d2f2e-fc7c-404a-96ac-92db54558df4

Motivation and Use Case

Current Problem:

  • Users must wait for full download every time they access an attachment (PDF, images, documents, etc.)
  • Multiple downloads occur for the same file if accessed multiple times
  • Unnecessary data usage and battery drain
  • Poor user experience with slow file access in chat

Use Cases:

  • Frequent Reference: Users accessing the same important documents multiple times during a work session
  • Offline Access: Users wanting to quickly access previously viewed files without internet
  • Data Conservation: Users on limited data plans wanting to avoid repeated downloads
  • Quick Review: Users rapidly switching between different attachments in a conversation
Implementation Ideas

Based on the current implementation provided:
export const fileDownload = async ( url: string, attachment?: IAttachment, fileName?: string ): Promise<string> => { let path = ${FileSystem.documentDirectory}; if (fileName) { path = ${path}${sanitizeFileName(fileName)}; } if (attachment?.title) { path = ${path}${sanitizeFileName(attachment.title)}`;
}

// Check if file exists in cache first using existing cache system
const cache = await getMediaCache({
type: 'other' as const,
mimeType: attachment?.format,
urlToCache: url
});

if (cache?.exists) {
return cache.uri; // Return cached file URI if exists
}

// Create download options for media file
const option = {
messageId: url,
type: 'other' as const,
downloadUrl: url
};

// Download file if not cached
const uri = await downloadMediaFile(option);
return uri;
};`

profile
Qwen3-Coder
12:47 am
Feature Request: Implement Download Caching for Chat Attachments
Feature Description
Implement a caching system for chat attachment downloads that stores files locally after first download, allowing subsequent access to use cached versions instead of re-downloading. This will significantly improve user experience by reducing download times, saving data usage, and eliminating redundant downloads for the same file.

Motivation and Use Case
Current Problem:

Users must wait for full download every time they access an attachment (PDF, images, documents, etc.)
Multiple downloads occur for the same file if accessed multiple times
Unnecessary data usage and battery drain
Poor user experience with slow file access in chat
Use Cases:

Frequent Reference: Users accessing the same important documents multiple times during a work session
Offline Access: Users wanting to quickly access previously viewed files without internet
Data Conservation: Users on limited data plans wanting to avoid repeated downloads
Quick Review: Users rapidly switching between different attachments in a conversation
Implementation Ideas
Based on the current implementation provided:

export const fileDownload = async (
 url: string, 
 attachment?: IAttachment, 
 fileName?:  string
): Promise<string> => {
 let path = `${FileSystem.documentDirectory}`;
 if (fileName) {
   path = `${path}${sanitizeFileName(fileName)}`;
 }
 if (attachment?.title) {
   path = `${path}${sanitizeFileName(attachment.title)}`;
 }

 // Check if file exists in cache first using existing cache system
 const cache = await getMediaCache({ 
   type: 'other' as const, 
   mimeType: attachment?.format, 
   urlToCache: url 
 });

 if (cache?.exists) {
   return cache.uri; // Return cached file URI if exists
 }
 
 // Create download options for media file
 const option = {
   messageId: url,
   type: 'other' as const,
   downloadUrl: url
 };

 // Download file if not cached
 const uri = await downloadMediaFile(option);
 return uri;
};

Key Implementation Benefits:

  • Leverages existing cache system: Uses the existing getMediaCache function for consistency
  • Simple cache check: Checks if file exists before initiating download
  • Integrates with existing download logic: Uses downloadMediaFile for actual download
  • Maintains backward compatibility: Works with existing attachment handling
  • Efficient: Only downloads when necessary, returns cached version otherwise
Is this feature available in the API or web version?

Available in API

Rocket.Chat Server Version

NA

Rocket.Chat App Version

4.66.0

Device Name

POCO M2 Pro

OS Version

Android

Additional Context

This feature will particularly benefit users who:

  • Work with document-heavy conversations
  • Have limited internet connectivity
  • Need quick access to frequently referenced files
  • Want to conserve mobile data usage
Lingua principale
TypeScript
Stelle
2.4k
Fork
1.5k
Merge medio
1g 15h
PR unite (30g)
29

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RocketChat/Rocket.Chat.ReactNative

Tutte le issue di RocketChat/Rocket.Chat.ReactNative

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.