From 4f97ca7b6b8cc6a5217b10d134f252fbb314f1c7 Mon Sep 17 00:00:00 2001 From: padreug Date: Mon, 11 Aug 2025 02:34:48 +0200 Subject: [PATCH] refactor: Remove console logging and improve code clarity in useMarket composable - Replace console.log statements with comments to enhance code readability and maintainability. - Streamline the loading and processing of market, stall, and product events by removing unnecessary logging. - Ensure that the code remains functional while improving overall clarity for future development. --- src/composables/useMarket.ts | 41 +++++++++++++++++------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/composables/useMarket.ts b/src/composables/useMarket.ts index 546bd91..b75d0a0 100644 --- a/src/composables/useMarket.ts +++ b/src/composables/useMarket.ts @@ -41,7 +41,7 @@ export function useMarket() { isLoading.value = true error.value = null - console.log('Loading market from naddr:', naddr) + // Load market from naddr // Parse naddr to get market data const marketData = { @@ -67,7 +67,7 @@ export function useMarket() { // Load market data from Nostr events const loadMarketData = async (marketData: any) => { try { - console.log('Loading market data for:', marketData) + // Load market data from Nostr events // Fetch market configuration event const events = await relayHub.queryEvents([ @@ -78,11 +78,11 @@ export function useMarket() { } ]) - console.log('Found market events:', events.length) + // Process market events if (events.length > 0) { const marketEvent = events[0] - console.log('Market event:', marketEvent) + // Process market event const market = { d: marketData.identifier, @@ -95,7 +95,7 @@ export function useMarket() { marketStore.addMarket(market) marketStore.setActiveMarket(market) } else { - console.warn('No market events found') + // No market events found, create default // Create a default market if none exists const market = { d: marketData.identifier, @@ -145,13 +145,11 @@ export function useMarket() { return } - const merchants = [...(activeMarket.opts.merchants || [])] - console.log('Loading stalls from market merchants:', merchants) - - if (merchants.length === 0) { - console.log('No merchants in market, skipping stall loading') - return - } + const merchants = [...(activeMarket.opts.merchants || [])] + + if (merchants.length === 0) { + return + } // Fetch stall events from market merchants only const events = await relayHub.queryEvents([ @@ -161,7 +159,7 @@ export function useMarket() { } ]) - console.log('Found stall events:', events.length) + // Process stall events // Group events by stall ID and keep only the most recent version const stallGroups = new Map() @@ -212,10 +210,9 @@ export function useMarket() { } const merchants = [...(activeMarket.opts.merchants || [])] - if (merchants.length === 0) { - console.log('No merchants in market, skipping product loading') - return - } + if (merchants.length === 0) { + return + } // Fetch product events from market merchants const events = await relayHub.queryEvents([ @@ -225,7 +222,7 @@ export function useMarket() { } ]) - console.log('Found product events:', events.length) + // Process product events // Group events by product ID and keep only the most recent version const productGroups = new Map() @@ -344,7 +341,7 @@ export function useMarket() { // Handle incoming market events const handleMarketEvent = (event: any) => { - console.log('Received market event:', event) + // Process market event switch (event.kind) { case MARKET_EVENT_KINDS.MARKET: @@ -470,7 +467,7 @@ export function useMarket() { // Connect to market const connectToMarket = async () => { try { - console.log('Connecting to market...') + // Connect to market // Connect to relay hub await relayHub.connect() @@ -480,7 +477,7 @@ export function useMarket() { throw new Error('Failed to connect to Nostr relays') } - console.log('Connected to market') + // Market connected successfully // Load market data await loadMarketData({ @@ -506,7 +503,7 @@ export function useMarket() { const disconnectFromMarket = () => { isConnected.value = false error.value = null - console.log('Disconnected from market') + // Market disconnected } // Initialize market on mount