One refresh timer for the whole app, not one per useUserInfo()

Performancekamo-internal
Shipped
2026年8月26日 3:42 UTC
Author
kamo
Commit
10cb7a4

useUserInfo has 194 call sites, roughly a dozen of them mounted for the entire session — the nav, the shell providers, the launchpad. Each instance armed its own 5-minute interval and its own visibilitychange listener, so the app carried about a dozen timers and a dozen listeners all doing the same thing at the same moment. They share one of each now. Every subscriber still refreshes its own state exactly as before, so nothing about how admin-driven rights changes propagate is different — this is only about not arming a dozen timers to trigger one piece of work. The requests were already coalesced by loadUserInfoShared and refreshSessionShared, so the network side was never the problem. One deliberate behaviour difference, and it is an improvement: instances used to tick on their own mount-time offsets, and now they share a cadence. Firing together is what lets the coalescer actually collapse them into a single request; staggered ticks each paid for their own round trip. The timer and listener are created when the first subscriber arrives and torn down when the last leaves, so an unauthenticated surface with no useUserInfo() consumer arms nothing. fireSessionRefresh copies the subscriber set before iterating, so a component unmounting mid-sweep cannot reshape the collection underneath it. Deliberately NOT done: moving the hook's state itself into a shared store. That would collapse the ~12 dirty React roots on tab focus down to one, which is the larger half of this finding — but it restructures the state model of the hook that gates rights and auth across 194 call sites, and the failure mode is stale or wrong rights, which no test here would catch. It wants a reviewer who can exercise the app. Verified: tsc --noEmit clean over useUserInfo, useSoftphone and AuthedChrome with their transitive imports; all 10 guards pass; 66 tests across the hooks, session and voip suites pass.

All changes

配送を見るのが好きですか?

これらのアップデートは、自動的にワークスペースに埋め込まれます。 週1回無料スタートし、週1回生育する.

永遠に無料で始める料金を見る