Enhance market module with authentication service integration
- Inject AuthService into useMarket for improved user authentication checks. - Add error handling for missing AuthService and RelayHub to ensure proper module installation. - Update comments to clarify the use of pubkey from either nostrStore or AuthService, indicating a need for confirmation on the preferred source. - Refactor NostrmarketService to utilize injected RelayHub, improving error handling and code clarity.
This commit is contained in:
parent
fec577ba39
commit
e504b1f7e2
2 changed files with 18 additions and 3 deletions
|
|
@ -16,11 +16,16 @@ export function useMarket() {
|
|||
const nostrStore = useNostrStore()
|
||||
const marketStore = useMarketStore()
|
||||
const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB) as any
|
||||
const authService = injectService(SERVICE_TOKENS.AUTH_SERVICE) as any
|
||||
|
||||
if (!relayHub) {
|
||||
throw new Error('RelayHub not available. Make sure base module is installed.')
|
||||
}
|
||||
|
||||
if (!authService) {
|
||||
throw new Error('AuthService not available. Make sure base module is installed.')
|
||||
}
|
||||
|
||||
// State
|
||||
const isLoading = ref(false)
|
||||
const error = ref<Error | null>(null)
|
||||
|
|
@ -48,6 +53,7 @@ export function useMarket() {
|
|||
// Load market from naddr
|
||||
|
||||
// Parse naddr to get market data
|
||||
// TODO: Confirm if this should use nostrStore.account?.pubkey or authService.user.value?.pubkey
|
||||
const marketData = {
|
||||
identifier: naddr.split(':')[2] || 'default',
|
||||
pubkey: naddr.split(':')[1] || nostrStore.account?.pubkey || ''
|
||||
|
|
@ -469,6 +475,7 @@ export function useMarket() {
|
|||
|
||||
// Load market data
|
||||
console.log('🛒 Loading basic market data...')
|
||||
// TODO: Confirm if this should use nostrStore.account?.pubkey or authService.user.value?.pubkey
|
||||
await loadMarketData({
|
||||
identifier: 'default',
|
||||
pubkey: nostrStore.account?.pubkey || ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue