refactor: Remove console logging for error handling in useMarket and useMarketPreloader
- Eliminate console.log and console.warn statements to enhance code clarity and maintainability. - Replace error logging with comments to silently handle errors during market, stall, and product loading processes. - Streamline the preloading process by removing unnecessary logging, improving overall code readability.
This commit is contained in:
parent
786e27ab61
commit
06bcc4b91e
3 changed files with 11 additions and 47 deletions
|
|
@ -57,7 +57,6 @@ export function useMarket() {
|
|||
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err : new Error('Failed to load market')
|
||||
console.error('Error loading market:', err)
|
||||
throw err
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
|
|
@ -115,7 +114,6 @@ export function useMarket() {
|
|||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error loading market data:', err)
|
||||
// Don't throw error, create default market instead
|
||||
const market = {
|
||||
d: marketData.identifier,
|
||||
|
|
@ -141,7 +139,6 @@ export function useMarket() {
|
|||
// Get the active market to filter by its merchants
|
||||
const activeMarket = marketStore.activeMarket
|
||||
if (!activeMarket) {
|
||||
console.warn('No active market found')
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -191,12 +188,12 @@ export function useMarket() {
|
|||
|
||||
marketStore.addStall(stall)
|
||||
} catch (err) {
|
||||
console.warn('Failed to parse stall data:', err)
|
||||
// Silently handle parse errors
|
||||
}
|
||||
})
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error loading stalls:', err)
|
||||
// Silently handle stall loading errors
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +202,6 @@ export function useMarket() {
|
|||
try {
|
||||
const activeMarket = marketStore.activeMarket
|
||||
if (!activeMarket) {
|
||||
console.warn('No active market found')
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -260,12 +256,12 @@ export function useMarket() {
|
|||
|
||||
marketStore.addProduct(product)
|
||||
} catch (err) {
|
||||
console.warn('Failed to parse product data:', err)
|
||||
// Silently handle parse errors
|
||||
}
|
||||
})
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error loading products:', err)
|
||||
// Silently handle product loading errors
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +310,6 @@ export function useMarket() {
|
|||
try {
|
||||
const activeMarket = marketStore.activeMarket
|
||||
if (!activeMarket) {
|
||||
console.warn('No active market found for subscription')
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
@ -334,7 +329,6 @@ export function useMarket() {
|
|||
|
||||
return unsubscribe
|
||||
} catch (error) {
|
||||
console.error('Failed to subscribe to market updates:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
@ -370,7 +364,6 @@ export function useMarket() {
|
|||
})
|
||||
|
||||
if (productsWithoutStalls.length > 0) {
|
||||
console.log('Found products without stalls:', productsWithoutStalls.length)
|
||||
// You could create default stalls or handle this as needed
|
||||
}
|
||||
}
|
||||
|
|
@ -393,7 +386,7 @@ export function useMarket() {
|
|||
marketStore.addStall(stall)
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Failed to handle stall event:', err)
|
||||
// Silently handle stall event errors
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +415,7 @@ export function useMarket() {
|
|||
marketStore.addProduct(product)
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Failed to handle product data:', err)
|
||||
// Silently handle product event errors
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -445,23 +438,22 @@ export function useMarket() {
|
|||
updated_at: event.created_at
|
||||
}
|
||||
|
||||
// Note: addOrder method doesn't exist in the store, so we'll just log it
|
||||
console.log('Received order event:', order)
|
||||
// Note: addOrder method doesn't exist in the store, so we'll just handle it silently
|
||||
} catch (err) {
|
||||
console.warn('Failed to handle order event:', err)
|
||||
// Silently handle order event errors
|
||||
}
|
||||
}
|
||||
|
||||
// Publish a product
|
||||
const publishProduct = async (_productData: any) => {
|
||||
// Implementation would depend on your event creation logic
|
||||
console.log('Publishing product:', _productData)
|
||||
// TODO: Implement product publishing
|
||||
}
|
||||
|
||||
// Publish a stall
|
||||
const publishStall = async (_stallData: any) => {
|
||||
// Implementation would depend on your event creation logic
|
||||
console.log('Publishing stall:', _stallData)
|
||||
// TODO: Implement stall publishing
|
||||
}
|
||||
|
||||
// Connect to market
|
||||
|
|
@ -494,7 +486,6 @@ export function useMarket() {
|
|||
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err : new Error('Failed to connect to market')
|
||||
console.error('Error connecting to market:', err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,9 @@ export function useMarketPreloader() {
|
|||
|
||||
const naddr = config.market.defaultNaddr
|
||||
if (!naddr) {
|
||||
console.log('No market naddr configured, skipping preload')
|
||||
return
|
||||
}
|
||||
|
||||
console.log('Preloading market data...')
|
||||
|
||||
// Connect to market
|
||||
await market.connectToMarket()
|
||||
|
||||
|
|
@ -39,10 +36,8 @@ export function useMarketPreloader() {
|
|||
marketStore.setError(null)
|
||||
|
||||
isPreloaded.value = true
|
||||
console.log('Market data preloaded successfully')
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to preload market:', error)
|
||||
preloadError.value = error instanceof Error ? error.message : 'Failed to preload market'
|
||||
// Don't throw error, let the UI handle it gracefully
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -127,16 +127,6 @@ const isMarketReady = computed(() => {
|
|||
const ready = marketPreloader.isPreloaded.value ||
|
||||
(marketStore.products.length > 0 && !isLoading)
|
||||
|
||||
// Debug logging
|
||||
console.log('Market ready check:', {
|
||||
isPreloaded: marketPreloader.isPreloaded.value,
|
||||
productsLength: marketStore.products.length,
|
||||
isLoading: isLoading,
|
||||
isReady: ready,
|
||||
error: marketStore.error,
|
||||
preloadError: marketPreloader.preloadError
|
||||
})
|
||||
|
||||
return ready
|
||||
})
|
||||
|
||||
|
|
@ -147,19 +137,13 @@ const loadMarket = async () => {
|
|||
throw new Error('No market naddr configured')
|
||||
}
|
||||
|
||||
console.log('Connecting to market...')
|
||||
await market.connectToMarket()
|
||||
console.log('Connected to market')
|
||||
|
||||
console.log('Loading market...')
|
||||
await market.loadMarket(naddr)
|
||||
console.log('Market loaded')
|
||||
|
||||
// Subscribe to real-time updates
|
||||
unsubscribe = market.subscribeToMarketUpdates()
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to load market:', error)
|
||||
marketStore.setError(error instanceof Error ? error.message : 'Failed to load market')
|
||||
}
|
||||
}
|
||||
|
|
@ -176,25 +160,19 @@ const addToCart = (product: any) => {
|
|||
|
||||
const viewProduct = (product: any) => {
|
||||
// TODO: Navigate to product detail page
|
||||
console.log('View product:', product)
|
||||
}
|
||||
|
||||
const viewCart = () => {
|
||||
// TODO: Navigate to cart page
|
||||
console.log('View cart')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// Only load market if it hasn't been preloaded
|
||||
if (needsToLoadMarket.value) {
|
||||
console.log('Market not preloaded, loading now...')
|
||||
loadMarket()
|
||||
} else if (marketPreloader.isPreloaded.value) {
|
||||
console.log('Market was preloaded, subscribing to updates...')
|
||||
// Subscribe to real-time updates if market was preloaded
|
||||
unsubscribe = market.subscribeToMarketUpdates()
|
||||
} else {
|
||||
console.log('Market data is ready, no additional loading needed')
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue