Bug: Settings reset on reload & Potential crash in utils
- Dominant language
- JavaScript
- Stars
- 39.5k
- Forks
- 3.2k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 16
Description
**Describe the bug**
1. `SettingsContext` resets settings to defaults on every page reload because it initializes state with defaults and only reads from localStorage in a `useEffect`, which causes settings to be overwritten.
2. `dataURItoBlob` in `utils.js` lacks error handling for malformed data URIs, which can cause the app to crash.
**To Reproduce**
1. Change settings (e.g., turn off grid).
2. Reload page.
3. Settings are back to default (grid is on).
**Expected behavior**
Settings should persist across reloads.
**Proposed Fix**
- Initialize `SettingsContext` state lazily from `localStorage` to ensure settings are loaded before first render.
- Add error handling to `dataURItoBlob` to handle invalid inputs gracefully.
I have a PR ready with these fixes.
Contributor guide
Assessment
This issue has not been assessed yet.