From 5171b24ba38b153c4375611938b4cb240bc7d5e5 Mon Sep 17 00:00:00 2001 From: padreug Date: Tue, 21 Oct 2025 23:05:38 +0200 Subject: [PATCH] Uses array for completions to improve reactivity Changes the `allCompletions` computed property to return an array instead of a Map. This improves reactivity in the component that uses it, as Vue can more efficiently track changes in an array. Also simplifies the pubkey extraction process. --- src/modules/nostr-feed/components/NostrFeed.vue | 8 +++----- src/modules/nostr-feed/composables/useScheduledEvents.ts | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/modules/nostr-feed/components/NostrFeed.vue b/src/modules/nostr-feed/components/NostrFeed.vue index e9592e5..1061ea5 100644 --- a/src/modules/nostr-feed/components/NostrFeed.vue +++ b/src/modules/nostr-feed/components/NostrFeed.vue @@ -144,11 +144,9 @@ watch(todaysScheduledEvents, async (events) => { // Watch for new completions and fetch profiles for completers watch(allCompletions, async (completions) => { - if (completions.size > 0) { - const pubkeys = [...completions.values()].map(c => c.pubkey) - if (pubkeys.length > 0) { - await fetchProfiles(pubkeys) - } + if (completions.length > 0) { + const pubkeys = completions.map(c => c.pubkey) + await fetchProfiles(pubkeys) } }, { immediate: true }) diff --git a/src/modules/nostr-feed/composables/useScheduledEvents.ts b/src/modules/nostr-feed/composables/useScheduledEvents.ts index d49384c..ae79702 100644 --- a/src/modules/nostr-feed/composables/useScheduledEvents.ts +++ b/src/modules/nostr-feed/composables/useScheduledEvents.ts @@ -125,10 +125,11 @@ export function useScheduledEvents() { }) /** - * Get all completions (reactive) + * Get all completions (reactive) - returns array for better reactivity */ const allCompletions = computed(() => { - return scheduledEventService?.completions ?? new Map() + if (!scheduledEventService?.completions) return [] + return Array.from(scheduledEventService.completions.values()) }) return {