Skip to content

refactor: abstract community reports localStorage access - #688

Merged
Aditya8369 merged 1 commit into
Aditya8369:mainfrom
Suprita736:enhancement/abstract-localstorage-access
Aug 12, 2026
Merged

refactor: abstract community reports localStorage access#688
Aditya8369 merged 1 commit into
Aditya8369:mainfrom
Suprita736:enhancement/abstract-localstorage-access

Conversation

@Suprita736

Copy link
Copy Markdown
Contributor

Pull Request

Description

Extracts the LocationMap component's direct localStorage access for community reports into a new useCommunityReports hook, so the component no longer owns that side effect directly and the hook's return value can be mocked in tests.

Related Issue

Closes #626

Type of Change

  • Refactoring

Changes Made

  • Added src/hooks/useCommunityReports.js, encapsulating the localStorage read, COMMUNITY_REPORT_SUBMITTED event subscription, and cross-tab storage event sync previously inline in LocationMap.jsx.
  • LocationMap.jsx now consumes useCommunityReports() instead of managing its own state/effect for community reports; storage key constant, reader function, and the associated useEffect were removed from the component.

Testing

  • Tested locally
  • No console errors
  • Existing functionality works as expected

Checklist

  • My code follows the project guidelines.
  • I have tested my changes.
  • I have updated the documentation if required.
  • My changes address the related issue.
  • This PR focuses on a single issue.

Additional Notes

Symptom reports still read localStorage inline in LocationMap.jsx — left untouched since #626 scopes only community reports. Could be a good follow-up issue (useSymptomReports) if desired.

@Suprita736
Suprita736 requested a review from Aditya8369 as a code owner August 12, 2026 06:48
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

@Suprita736 is attempting to deploy a commit to the Aditya Mahajan's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

Thank You for Your Contribution! 🎉

Hi @Suprita736,

Thank you for opening this Pull Request and contributing to our project. We truly appreciate your efforts.

Please make sure that:

  • Your code follows the project's guidelines.
  • You have linked the appropriate issue (if applicable).
  • Screenshots are added for UI/UX changes.
  • Your PR is ready for review.

The maintainer @Aditya8369 will review your PR shortly!

Happy Contributing! 🚀

@github-actions github-actions Bot added the ECSoC26 Contributions considered under ECSoC'26 label Aug 12, 2026
@Aditya8369
Aditya8369 merged commit 470aa05 into Aditya8369:main Aug 12, 2026
3 of 9 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Your PR just got merged, @Suprita736 — thank you for contributing to Pollution Control Hub!

Your work is now part of the project. Here's what to do next:

  • ⭐ If you haven't already, consider giving the repo a star — it helps us grow.
  • 📢 Share your contribution on LinkedIn, Twitter, or wherever you hang out. You shipped open source!
  • 🔍 Browse other open issues if you want to keep contributing.

We really appreciate you taking the time. See you in the next PR! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ECSoC26-L2 ECSoC26 Contributions considered under ECSoC'26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abstract LocalStorage Access

2 participants