PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

Bug Fix: Prevent PersonImages from polluting global image state

Open VasuS609 opened this issue 11 months ago • 4 comments

fixe:#706

Problem

PersonImages component was overwriting global Redux image state, causing the Home page gallery to display only the last viewed person's images instead of the full gallery.

Reproduction Steps

  1. Open Home → see full gallery (e.g., 100 photos)
  2. Click a face collection → see person's photos (e.g., 15 photos)
  3. Navigate back to Home → Bug: only 15 photos shown instead of 100

Solution

  • Changed from dispatch(setImages) to local useState(personImages)
  • Person-specific images now isolated to component state
  • Global Redux state remains clean for Home and search pages
  • Added loading spinner and empty state for better UX

Changes

  • src/pages/PersonImages/PersonImages.tsx - Use local state + improved loading/empty states

Testing

Home shows full gallery
Person page shows only their images
Navigating back preserves full gallery
Loading state displays during fetch
Empty state shows when no images found

##fixes:#706

Summary by CodeRabbit

  • Refactor

    • Image state moved from global store to local component state for improved performance and maintainability.
  • Improvements

    • Inline handling of loading, error, and empty states with clearer messaging and spinner.
    • Media viewer and image grid now use the local image set.
    • Simplified image editing/save flow for a more consistent UX.

✏️ Tip: You can customize this high-level summary in your review settings.

VasuS609 avatar Dec 11 '25 12:12 VasuS609

⚠️ No issue was linked in the PR description. Please make sure to link an issue (e.g., 'Fixes #issue_number')

github-actions[bot] avatar Dec 11 '25 12:12 github-actions[bot]

[!WARNING]

Rate limit exceeded

@VasuS609 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2f8a08866e6764fe05f69d176f941fa322efc94e and 64805ba70d80d80c951f984c6165050942487bb2.

📒 Files selected for processing (1)
  • frontend/src/pages/PersonImages/PersonImages.tsx (4 hunks)

Walkthrough

PersonImages now stores fetched images in local component state (personImages) instead of using Redux; rendering, loading/error/empty states, editing flow, and MediaView usage were updated to read from that local state.

Changes

Cohort / File(s) Summary
Local state migration & render/update
frontend/src/pages/PersonImages/PersonImages.tsx
Removed Redux image selector/dispatcher (selectImages, setImages); added useState for personImages; populate personImages on fetch success and update clusterName there; render now uses isLoading/error/personImages with spinner and "No images found" messaging; pass personImages to MediaView; removed clusterName updates from edit/save flows and inline loading/error UI handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify initialization and TypeScript typing of personImages useState
  • Confirm fetch success/error paths update personImages and clusterName correctly
  • Ensure MediaView accepts the personImages shape and viewer behavior remains intact
  • Check that removing Redux image updates does not break other components expecting global image state

Possibly related PRs

  • AOSSIE-Org/PictoPy#578 — Related changes to MediaView image-data handling; may overlap or conflict with how images are now passed from PersonImages to MediaView

Suggested labels

frontend, UI

Poem

🐰 A little hop from store to state,
Images snug in a local crate,
Spinners twirl while empty notes chime,
Viewer opens with the fetched batch in time,
Hoppity-hop — the UI feels great! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: replacing global Redux image state usage with local component state to prevent the PersonImages component from polluting the global state.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Dec 11 '25 12:12 coderabbitai[bot]

⚠️ No issue was linked in the PR description. Please make sure to link an issue (e.g., 'Fixes #issue_number')

github-actions[bot] avatar Dec 11 '25 12:12 github-actions[bot]

⚠️ This PR has merge conflicts.

Please resolve the merge conflicts before review.

Your PR will only be reviewed by a maintainer after all conflicts have been resolved.

📺 Watch this video to understand why conflicts occur and how to resolve them: https://www.youtube.com/watch?v=Sqsz1-o7nXk

github-actions[bot] avatar Jun 16 '26 09:06 github-actions[bot]