refactor: use unified manager design

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-06-20 19:25:00 -04:00
parent ae4c68e9c2
commit 583e6a3359
3 changed files with 26 additions and 38 deletions
+18 -20
View File
@@ -22,7 +22,15 @@ const emit = defineEmits<{
// State
const loading = ref(false)
const searchQuery = ref('')
const collectionEntities = ref<EntityObject[]>([])
// Entities belonging to the selected collection, sourced live from the manager store
const collectionEntities = computed<EntityObject[]>(() => {
const collection = props.selectedCollection
if (!collection) {
return []
}
return entitiesStore.entitiesForCollection(collection.identifier)
})
// Computed
const filteredEntities = computed(() => {
@@ -46,25 +54,15 @@ const filteredEntities = computed(() => {
// Watchers
watch(() => props.selectedCollection, async (newCollection) => {
if (newCollection) {
loading.value = true
try {
const sources = {
[newCollection.provider]: {
[String(newCollection.service)]: {
[String(newCollection.identifier)]: true as const,
},
},
}
const result = await entitiesStore.list(sources)
collectionEntities.value = Object.values(result)
} catch (error) {
console.error('[People] - Failed to load contacts:', error)
} finally {
loading.value = false
}
} else {
collectionEntities.value = []
if (!newCollection) {
return
}
loading.value = true
try {
await entitiesStore.list([newCollection.identifier])
} catch (error) {
console.error('[People] - Failed to load contacts:', error)
} finally {
loading.value = false
}
}, { immediate: true })