feat: add FavoritesService with Directus sync, union merge on login, localStorage migration

This commit is contained in:
2026-02-07 10:41:28 +01:00
parent fc1a1ede66
commit 0c51542df8
7 changed files with 202 additions and 48 deletions

View File

@@ -1,5 +1,6 @@
import { t, i18n } from '../../i18n.js'
import { auth } from '../../services/auth.js'
import { favoritesService } from '../../services/favorites.js'
class PageSettings extends HTMLElement {
constructor() {
@@ -63,9 +64,12 @@ class PageSettings extends HTMLElement {
})
// Clear favorites
this.querySelector('#clear-favorites')?.addEventListener('click', () => {
this.querySelector('#clear-favorites')?.addEventListener('click', async () => {
if (confirm(t('settings.confirmClearFavorites'))) {
localStorage.removeItem('favorites')
const ids = favoritesService.getAll()
for (const id of ids) {
await favoritesService.toggle(id)
}
this.showToast(t('settings.favoritesCleared'))
}
})