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

Đang mở Phù hợp với người mới
#342 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
87/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Lĩnh vực
frontend, full-stack

Hướng nghiên cứu

Đọc apps/web/src/components/Composer.tsx và kiểm tra cách thành phần này lấy ID người dùng hiện tại từ apps/web/src/store/auth.ts. Sau đó, làm theo mẫu lưu trữ tìm kiếm gần đây trong SearchPage.tsx và chạy các bài kiểm tra của thành phần Composer. Công việc hoàn tất khi bản nháp được khôi phục theo từng người dùng sau khi gắn lại, bị xóa khi đăng hoặc hủy, và lỗi lưu trữ không làm Composer gặp sự cố.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
6
Fork
6
Merge trung bình
6 giờ 7 phút
Pull request đã merge (30 ngày)
167

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Haseeb-MernStack/commune

Tất cả issue của Haseeb-MernStack/commune

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.