Fix: Verhindere Ueberschreiben von Nextcloud-Daten mit leeren Arrays

- In saveNextcloudConfig(): Nur speichern, wenn Daten vorhanden sind
- Falls keine lokalen Daten, aber Nextcloud hat Daten: behalte Nextcloud-Daten
- Verhindert Datenverlust, wenn Nextcloud bereits Daten hat

Fixes: Datenverlust bei Nextcloud-Anmeldung

Co-authored-by: trevor1969 <trevor1969@users.noreply.github.com>
This commit is contained in:
Vibe Nuage Agent
2026-06-05 11:28:05 +00:00
parent 7e1f52a5b2
commit 91367a7198

28
app.js
View File

@ -993,8 +993,34 @@ class TeeTracker {
// This will automatically fall back to localStorage if Nextcloud has no data
await this.loadData();
// Save the loaded/merged data to Nextcloud
// Only save to Nextcloud if we actually have data to save
// This prevents overwriting existing Nextcloud data with empty arrays
if (this.teas.length > 0 || this.entries.length > 0) {
await this.saveData();
} else {
// No data to save, but check if Nextcloud has existing data
const existingTeas = await ncStorage.loadFile(DATA_DIRECTORY + 'teas.json');
const existingEntries = await ncStorage.loadFile(DATA_DIRECTORY + 'entries.json');
// If Nextcloud has data, keep it and load it
if (existingTeas || existingEntries) {
if (existingTeas) {
this.teas = existingTeas.map(tea => ({
...tea,
organic: tea.organic !== undefined ? tea.organic : false,
rating: tea.rating !== undefined ? tea.rating : 3
}));
}
if (existingEntries) {
this.entries = existingEntries.map(entry => ({
...entry,
teaspoons: entry.teaspoons !== undefined ? entry.teaspoons : 1
}));
}
// Don't save, just use the existing Nextcloud data
}
// If Nextcloud has no data and we have no data, nothing to do
}
this.showStatusMessage('✅ Konfiguration gespeichert und Daten synchronisiert!', 'success');
} else {