feat(web): save the post you are writing as a draft

Abierto Apto para principiantes
#342 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
87/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, react, typescript

Línea de trabajo

Lee apps/web/src/components/Composer.tsx y comprueba cómo obtiene el ID del usuario actual de apps/web/src/store/auth.ts. Después, sigue el patrón de almacenamiento de búsquedas recientes de SearchPage.tsx y ejecuta las pruebas del componente Composer. El trabajo estará terminado cuando los borradores se restauren por usuario después de volver a montar el componente, se borren al publicar o descartar y los errores de almacenamiento no provoquen que Composer se bloquee.

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

Descripción

enhancement good first issue web

Summary

If someone closes the tab or refreshes while writing a post, the text is lost today. Save it locally and restore it.

Why this matters

Losing a long post is frustrating and makes people stop writing. A draft that survives a refresh or a flaky mobile connection is a basic quality of a production app.

Proposed solution

  • Save the composer text to localStorage (debounced, about 500 ms) under a key that includes the user id, for example commune:draft:<userId>.
  • Restore it when the composer mounts, show a small "Draft restored" note with a Discard button, and remove it after a successful post.
  • Do not save empty text, and wrap every storage call in try/catch because storage can be blocked.

Where to start in the code

  • apps/web/src/components/Composer.tsx
  • apps/web/src/store/auth.ts for the current user id
  • Follow the same storage pattern used by recent searches in SearchPage.tsx

Acceptance criteria

  • Refreshing the page keeps the text.
  • Posting clears the draft; discarding clears it too.
  • Another account on the same browser never sees someone else's draft.
  • Nothing breaks when localStorage throws.

Tests

  • Component test: typing, remounting the composer and finding the restored text.
  • Test that a failing localStorage does not crash the composer.

Want to work on this?

Comment on this issue to claim it, then follow First contribution and CONTRIBUTING.md. Keep the pull request to this one feature, use a conventional title (for example feat(web): save the post you are writing as a draft), write Closes #<this issue> in the description, and run npx prettier --write on the files you changed before pushing. Questions are welcome here or on Discord.


Generated by Claude Code

Lenguaje dominante
TypeScript
Estrellas
6
Forks
6
Merge medio
6 h 7 min
PR fusionados (30 d)
167

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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 Haseeb-MernStack/commune

Todos los issues de Haseeb-MernStack/commune

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.