feat: Prevent duplicate event processing in useMarket composable

- Introduce a Set to track processed event IDs, ensuring that each event is handled only once.
- Update event handling logic to skip already processed events, improving efficiency and data integrity.
This commit is contained in:
padreug 2025-08-04 08:49:28 +02:00
parent f3c66915a1
commit d38978f446

View file

@ -19,6 +19,9 @@ export function useMarket() {
const isLoading = ref(false)
const isConnected = ref(false)
// Track processed event IDs to prevent duplicates (like nostr-market-app)
const processedEventIds = new Set<string>()
// Market loading state
const loadMarket = async (naddr: string) => {
try {
@ -403,6 +406,10 @@ export function useMarket() {
}
const handleMarketEvent = (event: any) => {
// Skip if already processed
if (processedEventIds.has(event.id)) return
processedEventIds.add(event.id)
try {
switch (event.kind) {
case MARKET_EVENT_KINDS.STALL: