refactor: Simplify useMarket composable by removing unused client references and improving parameter naming

- Eliminate unnecessary Nostr client retrieval in publishProduct and publishStall functions.
- Update parameter names in event processing functions for clarity, using underscores for unused parameters.
- Clean up imports in useMarket.ts to streamline the codebase.
This commit is contained in:
padreug 2025-08-02 18:19:27 +02:00
parent 1fcc3706be
commit 8643eecfe7
3 changed files with 7 additions and 33 deletions

View file

@ -1,4 +1,4 @@
import { ref, computed, readonly } from 'vue'
import { ref, readonly } from 'vue'
import { useNostrStore } from '@/stores/nostr'
import { useMarketStore, type Market, type Stall, type Product } from '@/stores/market'
import { config } from '@/lib/config'
@ -54,8 +54,6 @@ export function useMarket() {
const loadMarketData = async (marketData: any) => {
try {
console.log('Starting loadMarketData...')
// Get Nostr client
const client = nostrStore.getClient()
console.log('Got Nostr client')
// Load market configuration
@ -193,7 +191,7 @@ export function useMarket() {
})
// Process each stall group, keeping only the most recent version
stallGroups.forEach((stallEvents, stallId) => {
stallGroups.forEach((stallEvents, _stallId) => {
// Sort by created_at timestamp (most recent first)
stallEvents.sort((a, b) => b.event.created_at - a.event.created_at)
@ -263,7 +261,7 @@ export function useMarket() {
})
// Process each product group, keeping only the most recent version
productGroups.forEach((productEvents, productId) => {
productGroups.forEach((productEvents, _productId) => {
// Sort by created_at timestamp (most recent first)
productEvents.sort((a, b) => b.event.created_at - a.event.created_at)
@ -476,20 +474,8 @@ export function useMarket() {
}
}
const publishProduct = async (productData: any) => {
const publishProduct = async (_productData: any) => {
try {
const client = nostrStore.getClient()
// Create unsigned event
const unsignedEvent = {
kind: MARKET_EVENT_KINDS.PRODUCT,
content: JSON.stringify(productData),
tags: [
['d', productData.id],
['t', 'product']
],
created_at: Math.floor(Date.now() / 1000)
}
// Note: This would need to be signed with the user's private key
// For now, we'll just log that this function needs to be implemented
@ -501,20 +487,8 @@ export function useMarket() {
}
}
const publishStall = async (stallData: any) => {
const publishStall = async (_stallData: any) => {
try {
const client = nostrStore.getClient()
// Create unsigned event
const unsignedEvent = {
kind: MARKET_EVENT_KINDS.STALL,
content: JSON.stringify(stallData),
tags: [
['d', stallData.id],
['t', 'stall']
],
created_at: Math.floor(Date.now() / 1000)
}
// Note: This would need to be signed with the user's private key
// For now, we'll just log that this function needs to be implemented