( userId: string | undefined, flags: ClientOnlySettingsFlags, )
| 270 | // replace drops whichever ones its `flags` had not loaded yet. It also loses a |
| 271 | // second tab's write landing between this read and the set. |
| 272 | const writeStoredFlags = ( |
| 273 | userId: string | undefined, |
| 274 | flags: ClientOnlySettingsFlags, |
| 275 | ): void => |
| 276 | storageWrapper.setItem( |
| 277 | clientOnlyFlagsKey(userId), |
| 278 | JSON.stringify({ ...readStoredFlags(userId), ...flags }), |
| 279 | ); |
| 280 | |
| 281 | // The one write that has to remove keys: a graduated flag leaves the store for |
| 282 | // good once the API holds it, which is what stops the migration repeating. |
no test coverage detected