mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 06:40:50 +00:00
The /medications card and table render the dose-derived stock (stockUnitsRemaining / stockDosesRemaining) straight from the GET /api/medications list payload, which reads through cachedSwr on the 60s-fresh + 10-min-stale medications bucket. Registering, adjusting, or deleting an inventory container changes that stock, but the inventory routes never invalidated any cache — so the list served the pre-write stock for the rest of the stale window. On the client the add / adjust / delete supply mutations only invalidated the per-medication inventory query, never the medications-list query that the card reads, so a mounted list never refetched even once the server caught up. Hard-evict the per-user medications + compliance buckets from every supply-affecting write (inventory POST, the per-item PATCH / DELETE, and the deprecated glp1 POST dose-change + ledger branches) so the next read reflects the change rather than a stale SWR value. On the client, centralise the supply mutations on a shared invalidateSupplyQueries helper that drops both the medications-list key and the per-medication inventory key. The card's neutral styling is unchanged.