| 32 | // value so no mutation races occur. |
| 33 | const _storePending = new Map(); |
| 34 | export function storeSetDebounced(key, value, delayMs = 300) { |
| 35 | if (_storePending.has(key)) clearTimeout(_storePending.get(key)); |
| 36 | const snapshot = structuredClone(value); |
| 37 | _storePending.set(key, setTimeout(() => { |
| 38 | _storePending.delete(key); |
| 39 | storeSet(key, snapshot); |
| 40 | }, delayMs)); |
| 41 | } |
| 42 | |
| 43 | // Keys that hold critical user data and must be migrated from localStorage |
| 44 | // to the store on first launch after this feature ships. |