From 1f321dce4a8aaea5022bd904bb66510e1d378aef Mon Sep 17 00:00:00 2001 From: padreug Date: Sat, 27 Sep 2025 15:54:47 +0200 Subject: [PATCH] refactor: update market loading logic and remove debug methods in MarketPage - Bypassed the naddr requirement for market configuration, allowing for more flexible market loading. - Implemented conditional loading of the market based on the availability of naddr, defaulting to a general market load if not provided. - Removed temporary debug methods for simulating loading and error states to clean up the codebase. These changes streamline the market loading process and enhance the overall clarity of the MarketPage component. --- src/modules/market/views/MarketPage.vue | 70 +++++-------------------- 1 file changed, 14 insertions(+), 56 deletions(-) diff --git a/src/modules/market/views/MarketPage.vue b/src/modules/market/views/MarketPage.vue index 95b1d36..8d4e15d 100644 --- a/src/modules/market/views/MarketPage.vue +++ b/src/modules/market/views/MarketPage.vue @@ -203,13 +203,22 @@ const productsToDisplay = computed(() => { const loadMarket = async () => { try { - const naddr = config.market.defaultNaddr - if (!naddr) { - throw new Error('No market naddr configured') - } + // TODO: Determine if we need naddr for market configuration + // Currently bypassing naddr requirement as it may not be needed + // Consider using naddr only for nostr-related configuration + // Original code: const naddr = config.market.defaultNaddr + // if (!naddr) throw new Error('No market naddr configured') await market.connectToMarket() - await market.loadMarket(naddr) + + // Load market with naddr if available, otherwise load default market + const naddr = config.market.defaultNaddr + if (naddr) { + await market.loadMarket(naddr) + } else { + // Load market without specific naddr - uses default market data + await market.loadMarket('') + } // Subscribe to real-time updates unsubscribe = market.subscribeToMarketUpdates() @@ -245,57 +254,6 @@ const handleCategoryFilter = (category: string) => { toggleCategory(category) } -// DEBUG: Temporary methods to test loading states (will be removed) -const simulateLoading = () => { - console.log('🔄 Simulating loading state...') - marketStore.setError(null) - marketStore.setLoading(true) - marketPreloader.resetPreload() - - setTimeout(() => { - console.log('✅ Simulating successful load') - marketStore.setLoading(false) - retryLoadMarket() - }, 3000) -} - -const simulateError = () => { - console.log('❌ Simulating error state...') - marketStore.setLoading(false) - marketStore.setError('Simulated error for testing') - marketPreloader.resetPreload() -} - -const debugLoadingState = () => { - const isLoading = marketStore.isLoading ?? false - const hasError = !!(marketStore.error || marketPreloader.preloadError.value) - - console.log('🔍 Loading State Debug:', { - isMarketReady: isMarketReady.value, - 'marketStore.isLoading': marketStore.isLoading, - 'marketStore.error': marketStore.error, - 'marketStore.products.length': marketStore.products.length, - 'marketPreloader.isPreloading': marketPreloader.isPreloading.value, - 'marketPreloader.preloadError': marketPreloader.preloadError.value, - 'marketPreloader.isPreloaded': marketPreloader.isPreloaded.value, - hasError, - '--- UI State ---': '---', - 'LoadingErrorState.isLoading': !isMarketReady.value && (isLoading || marketPreloader.isPreloading.value), - 'LoadingErrorState.hasError': hasError && !isMarketReady.value, - 'ShowMarketContent': isMarketReady.value - }) -} - -// Make debug methods available globally for testing -if (typeof window !== 'undefined') { - ;(window as any).debugMarketLoading = { - simulateLoading, - simulateError, - debugLoadingState, - retryLoadMarket - } -} - onMounted(() => { // Only load market if it hasn't been preloaded if (needsToLoadMarket.value) {