drawdb-io / drawdb-io/drawdb

Bug: Settings reset on reload & Potential crash in utils

Open
#752 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.