4 Commits

Author SHA1 Message Date
733e2db3c4 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>
2026-06-04 16:23:53 +00:00
30e0077c6e refactor: Remove CORS proxy code (not needed for same-domain setup)
- Remove NEXTCLOUD_PROXY constant
- Remove fetchWithProxy() and getProxiedUrl() methods
- Remove useProxy flag from NextcloudStorage
- Keep window.app onclick handlers for dynamically generated buttons
- Clean up code since Nextcloud and TeeTracker run on same domain (wralto.org)

Co-authored-by: trevor1969 <trevor1969@users.noreply.github.com>
2026-06-04 15:56:33 +00:00
7b9f509728 fix: Remove undefined error reference in fetchWithProxy catch block
- Fix reference to undefined 'error' variable in proxy error handler
- Use only proxyError.message in the error message

Co-authored-by: trevor1969 <trevor1969@users.noreply.github.com>
2026-06-04 15:32:44 +00:00
6addc628e8 fix: Add CORS proxy fallback for Nextcloud WebDAV connections
- Add NEXTCLOUD_PROXY constant for corsproxy.io
- Add getProxiedUrl() method to NextcloudStorage class
- Add fetchWithProxy() wrapper method that tries direct connection first,
  then falls back to CORS proxy if direct connection fails
- Update all fetch() calls in NextcloudStorage to use fetchWithProxy()
- Add useProxy flag to track proxy usage
- This fixes 'NetworkError when attempting to fetch resource' for servers
  like wralto.org/nextcloud3 that have CORS restrictions

Co-authored-by: trevor1969 <trevor1969@users.noreply.github.com>
2026-06-04 15:24:42 +00:00

24
app.js
View File

@ -778,6 +778,30 @@ class TeeTracker {
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
// Password will be requested each time or stored in sessionStorage
const config = { baseUrl: url, username, path };