feat: add FavoritesService with Directus sync, union merge on login, localStorage migration
This commit is contained in:
@@ -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'))
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user