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
39 changes: 28 additions & 11 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,34 @@ function App() {

useEffect(() => {
if (savingDisabledRef.current) return;
const serialized = uploadedFiles.map(({ id, name, enabled, content, config }) => ({
id,
name,
enabled,
content,
config
}));
if (serialized.length > 0) {
localStorage.setItem('uploadedFiles', JSON.stringify(serialized));
} else {
localStorage.removeItem('uploadedFiles');
try {
const serialized = uploadedFiles.map(({ id, name, enabled, content, config }) => ({
id,
name,
enabled,
content,
config
}));
if (serialized.length > 0) {
const json = JSON.stringify(serialized);
// Avoid filling localStorage with very large files
if (json.length > 5 * 1024 * 1024) {
savingDisabledRef.current = true;
console.warn('Uploaded files exceed storage limit; persistence disabled.');
return;
}
localStorage.setItem('uploadedFiles', json);
} else {
localStorage.removeItem('uploadedFiles');
}
} catch (err) {
if (err instanceof DOMException && err.name === 'QuotaExceededError') {
savingDisabledRef.current = true;
console.warn('LocalStorage quota exceeded; uploaded files will not be persisted.');
localStorage.removeItem('uploadedFiles');
} else {
throw err;
}
}
}, [uploadedFiles]);

Expand Down