Skip to content

fix individual gallery permission issue#1499

Merged
erinz2020 merged 16 commits intomainfrom
1449_fix_individual_gallery
Apr 16, 2026
Merged

fix individual gallery permission issue#1499
erinz2020 merged 16 commits intomainfrom
1449_fix_individual_gallery

Conversation

@erinz2020
Copy link
Copy Markdown
Contributor

PR fixes #1449

Filter out inaccessible encounters (access: "none") from gallery media results so restricted records do not prevent images from rendering.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 69.16667% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.53%. Comparing base (0a43260) to head (8188706).

Files with missing lines Patch % Lines
...src/pages/SearchPages/stores/EncounterFormStore.js 10.52% 17 Missing ⚠️
...pages/SearchPages/searchResultTabs/GalleryView.jsx 50.00% 15 Missing ⚠️
frontend/src/pages/SearchPages/EncounterSearch.jsx 92.95% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1499      +/-   ##
==========================================
- Coverage   52.54%   52.53%   -0.01%     
==========================================
  Files         278      278              
  Lines       10066    10145      +79     
  Branches     3097     3117      +20     
==========================================
+ Hits         5289     5330      +41     
- Misses       4524     4574      +50     
+ Partials      253      241      -12     
Flag Coverage Δ
backend 52.53% <69.16%> (-0.01%) ⬇️
frontend 52.53% <69.16%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erinz2020 erinz2020 added this to the 10.10 milestone Mar 12, 2026
@erinz2020

This comment was marked as outdated.

@claude

This comment was marked as outdated.

@erinz2020

This comment was marked as outdated.

@claude

This comment was marked as outdated.

@erinz2020
Copy link
Copy Markdown
Contributor Author

@claude please review again

@claude

This comment was marked as outdated.

@erinz2020

This comment was marked as outdated.

@claude

This comment was marked as outdated.

@erinz2020
Copy link
Copy Markdown
Contributor Author

@claude You are reviewing a code change as a senior engineer in an existing production codebase.

Your goal is to find only the most important issues that should realistically be addressed before merge.

Review principles:

Prioritize correctness, reliability, data flow, async behavior, state consistency, and real maintainability risks.
Do not comment on personal preference, code style, naming, or optional refactors.
Do not propose architecture changes unless the current implementation is clearly dangerous or broken.
Respect existing project conventions and favor minimal changes.
Do not invent missing requirements.
Be conservative: if something is acceptable, do not flag it.
Pay special attention to:

null / undefined access
React effect dependency mistakes
stale closures
race conditions
duplicate or inconsistent state
controlled/uncontrolled form issues
loading / error / empty-state logic
accidental rerenders with real impact
incorrect assumptions around async requests, polling, or derived data
Output:

Start with one line only:

"No merge-blocking issues found"
or "Found X important issues"
Then provide up to 3 issues only.

For each issue, use:

Severity: blocker | high | medium
Location: file / function / component
Problem:
Impact:
Minimal fix:
Do not include praise.
Do not include optional improvements.
Do not include “consider”, “might”, or “could” comments unless there is a concrete risk.

@claude
Copy link
Copy Markdown

claude bot commented Apr 15, 2026

Claude finished @erinz2020's task in 4m 51s —— View job


Code Review

  • Gathering context and reading changed files
  • Analyzing changes
  • Post findings

Found 2 important issues


Issue 1

  • Severity: medium

  • Location: EncounterSearch.jsxuseEffect([perPage])

  • Problem: When perPage changes, resetGallery() clears currentPageItems, start, assetOffset, and galleryExhausted, but pg() is never called afterward. In GalleryView, canFetchNextPage evaluates to false after a reset (because currentPageItems.length = 0 < pageSize), so canGoNext = false and the Next button is disabled. The gallery is left permanently empty with no mechanism to reload until the user switches tabs (unmounting and remounting GalleryView).

  • Impact: Changing per-page while viewing the gallery leaves the gallery in a permanently empty, non-interactive state. No way to recover without a full tab switch.

  • Minimal fix: Call pg() after resetGallery() in the effect:

    useEffect(() => {
      if (store.pageSize !== perPage) {
        store.setPageSize(perPage);
        store.resetGallery();
        pg();
      }
    }, [perPage]);

    Fix this →


Issue 2

  • Severity: medium

  • Location: EncounterSearch.jsxpg() / hasVisibleAssetsFromCursor call at line 222–226

  • Problem: store.setCurrentPageItems(contents), store.setStart(), and store.setAssetOffset() are committed to the store synchronously before hasVisibleAssetsFromCursor is awaited. The Prev button in GalleryView is not gated on store.galleryLoading (only on store.currentPage <= 0), so the user can navigate backward while the look-ahead is still in-flight. When hasVisibleAssetsFromCursor eventually resolves, store.setGalleryExhausted(!hasMore) fires against the previous page's state — potentially disabling or enabling the Next button incorrectly for that page.

  • Impact: After fast Prev navigation during a gallery load, the previous page's Next button can be permanently disabled (or incorrectly enabled), breaking forward pagination from a cached page.

  • Minimal fix: Snapshot the current page before the look-ahead and discard the result if the page changed:

    const pageSnapshot = store.currentPage;
    const hasMore = await hasVisibleAssetsFromCursor(cumulativeStart, assetOffset);
    if (store.currentPage === pageSnapshot) {
      store.setGalleryExhausted(!hasMore);
    }

    Fix this →


@JasonWildMe JasonWildMe self-requested a review April 16, 2026 20:24
Copy link
Copy Markdown
Collaborator

@JasonWildMe JasonWildMe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple rounds of review with Codex and Claude. Thank you for fixes. Approved.

@erinz2020 erinz2020 merged commit e1498c5 into main Apr 16, 2026
1 of 2 checks passed
@erinz2020 erinz2020 deleted the 1449_fix_individual_gallery branch April 16, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Individual gallery does not load in Chrome, Safari, or Edge

3 participants