fix(02-review): WR-04 require explicit persist on resources.ts entry()/optimistic()
entry(key, persist = true) and optimistic(key, update) silently defaulted
to persist:true after the first call for a key, and optimistic() didn't
accept a persist argument at all. Every current call site happened to be
safe, but the invariant was unenforced: a future caller invoking
store.optimistic() before any useCachedResource({persist:false}) has run
for that key in the same tick would silently start writing to
sessionStorage with no indication anything is wrong (T-02-01).
persist is now a required argument on both functions (no default), and the
per-key decision is recorded and asserted (dev-only warning) against any
later call that disagrees. useCachedResource's optimistic() wrapper now
threads its own already-resolved persist value through automatically, so
no existing composable caller changes behavior. The two call sites that
use the resources store directly (Cloud.vue/PeerFiles.vue's per-peer
browse cache) now pass persist:true explicitly, matching their existing
behavior exactly.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -643,7 +643,11 @@ interface PeerBrowse {
|
||||
}
|
||||
const peerOnion = computed(() => props.peerId || currentPeer.value?.onion || '')
|
||||
function browseEntry() {
|
||||
return resources.entry<PeerBrowse>(`cloud.peer-browse:${peerOnion.value}`)
|
||||
// persist:true matches this key's existing resources.refresh() call in
|
||||
// loadCatalog() below, which never passes `{ persist: false }` either —
|
||||
// WR-04 just makes that pre-existing decision explicit instead of relying
|
||||
// on a default.
|
||||
return resources.entry<PeerBrowse>(`cloud.peer-browse:${peerOnion.value}`, true)
|
||||
}
|
||||
const catalogItems = computed(() => browseEntry().data?.items ?? [])
|
||||
const catalogError = computed(() => browseEntry().error ?? '')
|
||||
|
||||
Reference in New Issue
Block a user