Problem
Two small client DRY gaps:
delay(ms) => new Promise(r => setTimeout(r, ms)) is duplicated 3x (staleChunkReload.js:68, lazyWithReload.js:9, voiceClient.js:644) with no client-side helper to point at.
client/src/hooks/useLocalStorageBool.js:55-93 hand-rolls its own readBool/writeBool/readJsonRaw/writeJson try/catch guards instead of delegating to client/src/lib/safeStorage.js primitives.
Approach (decided)
Add export const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); to client/src/utils/ (register in barrel + README), replace the 3 delay sites; rebuild useLocalStorageBool's internal helpers on safeStorage.js.
Acceptance
- One client
sleep helper used at the 3 sites; useLocalStorageBool delegates to safeStorage; tests pass.
Found by the /do:better audit (2026-07-21).
Problem
Two small client DRY gaps:
delay(ms) => new Promise(r => setTimeout(r, ms))is duplicated 3x (staleChunkReload.js:68,lazyWithReload.js:9,voiceClient.js:644) with no client-side helper to point at.client/src/hooks/useLocalStorageBool.js:55-93hand-rolls its ownreadBool/writeBool/readJsonRaw/writeJsontry/catch guards instead of delegating toclient/src/lib/safeStorage.jsprimitives.Approach (decided)
Add
export const sleep = (ms) => new Promise((r) => setTimeout(r, ms));toclient/src/utils/(register in barrel + README), replace the 3 delay sites; rebuilduseLocalStorageBool's internal helpers onsafeStorage.js.Acceptance
sleephelper used at the 3 sites;useLocalStorageBooldelegates tosafeStorage; tests pass.Found by the /do:better audit (2026-07-21).