mirror of
https://github.com/trevor1969/teatracker.git
synced 2026-08-09 10:41:59 +00:00
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:
28
app.js
28
app.js
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user