feature: Implement Download Caching for Chat Attachments

Abierto
#6,730 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@JASIM0021 ya está trabajando en esto.

Desde el 19/11/2025.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
react-native, typescript
Área
mobile

Línea de trabajo

Localiza el punto de entrada fileDownload y lee las implementaciones existentes de getMediaCache y downloadMediaFile; después, sigue cómo los archivos adjuntos del chat invocan las descargas. Se considera terminado cuando un archivo adjunto descargado anteriormente se sirve desde la caché local en accesos posteriores, mientras que los archivos adjuntos que no están en caché siguen descargándose normalmente; verifica el comportamiento mediante el flujo existente de archivos adjuntos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

🎉 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
Lenguaje dominante
TypeScript
Estrellas
2.4k
Forks
1.5k
Merge medio
1 d 15 h
PR fusionados (30 d)
29

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de RocketChat/Rocket.Chat.ReactNative

Todos los issues de RocketChat/Rocket.Chat.ReactNative

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.