fix(update-banner): fetch /version once by keying on a memoized admin flag (MAPPS-187) #180

Merged
vas2000-work merged 1 commit from fix/MAPPS-187-version-dedup into main 2026-06-16 02:02:22 +02:00
Owner

What

Completes MAPPS-187. The earlier PR (#176, merged) stopped the generation-keyed list resources from double-fetching on mount. This fixes the remaining /version duplicate: the UpdateBanner version_resource read the whole auth context, so it re-ran every time auth was written - and auth is written more than once during startup (OIDC callback, then rehydration) with the same user, firing a second GET /api/v1/version on every page.

Change

Derive is_admin with use_memo and key the resource (and the early-return) on that. A Memo<bool> only notifies when its value flips, so a redundant auth re-write with the same admin status no longer re-runs the resource. /version is fetched once.

Testing

  • cargo clippy --all-targets -- -D warnings: clean.
  • cargo check --target wasm32-unknown-unknown: clean.
  • cargo fmt --all --check: clean.
  • Per-page request count to be spot-checked via the network panel on staging once deployed (both code causes - generation-keyed and auth-keyed - are now addressed).
## What Completes MAPPS-187. The earlier PR (#176, merged) stopped the generation-keyed list resources from double-fetching on mount. This fixes the remaining `/version` duplicate: the `UpdateBanner` version_resource read the whole `auth` context, so it re-ran every time auth was written - and auth is written more than once during startup (OIDC callback, then rehydration) with the same user, firing a second `GET /api/v1/version` on every page. ## Change Derive `is_admin` with `use_memo` and key the resource (and the early-return) on that. A `Memo<bool>` only notifies when its value flips, so a redundant auth re-write with the same admin status no longer re-runs the resource. `/version` is fetched once. ## Testing - `cargo clippy --all-targets -- -D warnings`: clean. - `cargo check --target wasm32-unknown-unknown`: clean. - `cargo fmt --all --check`: clean. - Per-page request count to be spot-checked via the network panel on staging once deployed (both code causes - generation-keyed and auth-keyed - are now addressed).
fix(update-banner): fetch /version once by keying the check on a memoized admin flag (MAPPS-187)
All checks were successful
Create release / Create release from merged PR (pull_request) Has been skipped
Check / clippy + fmt + tests (pull_request) Successful in 1m6s
cf929bfe6c
The UpdateBanner version_resource read the whole auth context in its closure, so it re-ran every time auth was written - which happens more than once during startup (OIDC callback, then rehydration) with the same user, firing a duplicate GET /version on every page. Derive is_admin via use_memo and key the resource on that; the memo only notifies when admin-ness actually flips, so /version is fetched once. Completes the /version follow-up to the generation-guard fix (PR #176).

#MAPPS-187

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!180
No description provided.