Enhance Chat and Market Services with improved error handling and logging
Chat Service: - Added detailed logging for API calls and responses, including warnings for missing authentication tokens and invalid response formats. - Implemented a retry mechanism for message subscription setup on connection errors. - Merged peers instead of clearing existing ones when loading from the API. Market Service: - Updated authentication checks to prioritize global auth state, improving user experience during order placement. - Enhanced error messages for missing Nostr keys to guide users in configuring their profiles. These changes improve the robustness and user-friendliness of the chat and market functionalities.
This commit is contained in:
parent
034f3ce80f
commit
8a019db34a
3 changed files with 92 additions and 29 deletions
|
|
@ -272,6 +272,7 @@ import { ref, computed, onMounted } from 'vue'
|
|||
import { useRoute } from 'vue-router'
|
||||
import { useMarketStore } from '@/stores/market'
|
||||
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
||||
import { auth } from '@/composables/useAuth'
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
|
|
@ -411,21 +412,23 @@ const placeOrder = async () => {
|
|||
}
|
||||
// Debug logging to understand auth state
|
||||
console.log('Auth check:', {
|
||||
isAuthenticated: authService.isAuthenticated.value,
|
||||
user: authService.user.value,
|
||||
isAuthenticated: auth.isAuthenticated.value,
|
||||
user: auth.currentUser.value,
|
||||
userPubkey: auth.currentUser.value?.pubkey,
|
||||
authServiceUser: authService.user.value,
|
||||
hasPubkey: !!authService.user.value?.pubkey,
|
||||
nostrPubkey: authService.user.value?.pubkey
|
||||
})
|
||||
|
||||
// Get pubkey from auth service
|
||||
const userPubkey = authService.user.value?.pubkey
|
||||
// Try to get pubkey from main auth first, fallback to auth service
|
||||
const userPubkey = auth.currentUser.value?.pubkey || authService.user.value?.pubkey
|
||||
|
||||
if (!authService.isAuthenticated.value) {
|
||||
if (!auth.isAuthenticated.value) {
|
||||
throw new Error('You must be logged in to place an order')
|
||||
}
|
||||
|
||||
if (!userPubkey) {
|
||||
throw new Error('No Nostr public key found. Please ensure your Nostr identity is configured.')
|
||||
throw new Error('Nostr identity required: Please configure your Nostr public key in your profile settings to place orders.')
|
||||
}
|
||||
|
||||
// Create the order using the market store's order placement functionality
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue