refactor: reuse getConversations in messages, prevent duplicate favorites on sync

This commit is contained in:
2026-02-08 10:51:13 +01:00
parent 45e7f9dde7
commit 013d591e75
3 changed files with 8 additions and 24 deletions

View File

@@ -48,31 +48,8 @@ class PageMessages extends HTMLElement {
return
}
// Load conversations for current user (matched by participant hash)
const userHash = await auth.hashString(user.id)
const response = await directus.get('/items/conversations', {
fields: [
'id',
'date_created',
'date_updated',
'listing_id.id',
'listing_id.title',
'listing_id.status',
'listing_id.images.directus_files_id.id',
'status'
],
filter: {
_or: [
{ participant_hash_1: { _eq: userHash } },
{ participant_hash_2: { _eq: userHash } }
]
},
sort: ['-date_updated'],
limit: 50
})
this.conversations = response.data || []
this.conversations = await directus.getConversations(userHash) || []
this.loading = false
this.updateContent()
} catch (err) {