fix: Prevent data loss when connecting to Nextcloud for the first time

- Load existing data from localStorage before switching to Nextcloud
- This prevents existing teas and entries from being overwritten with empty arrays
- When enabling Nextcloud sync, existing local data is preserved and uploaded

Co-authored-by: trevor1969 <trevor1969@users.noreply.github.com>
This commit is contained in:
Vibe Nuage Agent
2026-06-04 16:23:53 +00:00
parent 30e0077c6e
commit 5b401e0dd6

24
app.js
View File

@ -778,6 +778,30 @@ class TeeTracker {
return; return;
} }
// Load existing data from localStorage before switching to Nextcloud
// This prevents data loss when connecting to Nextcloud for the first time
const existingTeas = localStorage.getItem(STORAGE_KEY_TEAS);
const existingEntries = localStorage.getItem(STORAGE_KEY_ENTRIES);
if (existingTeas) {
try {
this.teas = JSON.parse(existingTeas).map(tea => ({
...tea,
organic: tea.organic !== undefined ? tea.organic : false
}));
} catch (error) {
console.error('Error loading existing teas:', error);
}
}
if (existingEntries) {
try {
this.entries = JSON.parse(existingEntries);
} catch (error) {
console.error('Error loading existing entries:', error);
}
}
// Save config WITHOUT password for security // Save config WITHOUT password for security
// Password will be requested each time or stored in sessionStorage // Password will be requested each time or stored in sessionStorage
const config = { baseUrl: url, username, path }; const config = { baseUrl: url, username, path };