Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ditherbooth/static/designer-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
if (config && config.default_media) {
sel.value = config.default_media;
}
const saved = localStorage.getItem('ditherbooth_designer_media');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard localStorage access for blocked storage

Accessing localStorage can throw a SecurityError in environments where storage is blocked or disabled (e.g., Safari private mode, strict privacy settings). This new read runs during initialization, so a thrown error would abort the designer setup and leave the page unusable in those contexts. Consider wrapping the access in a try/catch or feature-checking storage availability before reading.

Useful? React with 👍 / 👎.

if (saved && sel.querySelector(`option[value="${saved}"]`)) {
sel.value = saved;
}
}

function isTouchDevice() {
Expand Down Expand Up @@ -851,6 +855,7 @@

$('#dFontSize').addEventListener('change', applyFontSize);
$('#dMedia').addEventListener('change', () => {
localStorage.setItem('ditherbooth_designer_media', $('#dMedia').value);
resizeCanvasToMedia();
drawGrid();
});
Expand Down