fix: Update useMarket composable to use unique IDs for stalls and products
- Modify the useMarket composable to utilize unique IDs from parsed stall and product data instead of Nostr event IDs for better data integrity. - Implement logging for unsigned event creation, indicating that signing with the user's private key is required for publishing products and stalls.
This commit is contained in:
parent
1ed8759162
commit
670270ca91
1 changed files with 16 additions and 8 deletions
|
|
@ -182,7 +182,7 @@ export function useMarket() {
|
|||
console.log('Parsed stall data:', stallData)
|
||||
|
||||
const stall: Stall = {
|
||||
id: event.id,
|
||||
id: stallData.id, // Use the stall's unique ID from content, not the Nostr event ID
|
||||
pubkey: event.pubkey,
|
||||
name: stallData.name,
|
||||
description: stallData.description,
|
||||
|
|
@ -237,7 +237,7 @@ export function useMarket() {
|
|||
|
||||
if (stall) {
|
||||
const product: Product = {
|
||||
id: event.id,
|
||||
id: productData.id, // Use the product's unique ID from content, not the Nostr event ID
|
||||
stall_id: stall.id,
|
||||
stallName: stall.name,
|
||||
name: productData.name,
|
||||
|
|
@ -442,16 +442,20 @@ export function useMarket() {
|
|||
try {
|
||||
const client = nostrStore.getClient()
|
||||
|
||||
const event = {
|
||||
// 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)
|
||||
}
|
||||
|
||||
await client.publishEvent(event)
|
||||
// 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
|
||||
console.log('Product publishing not yet implemented - needs private key signing')
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error publishing product:', err)
|
||||
|
|
@ -463,16 +467,20 @@ export function useMarket() {
|
|||
try {
|
||||
const client = nostrStore.getClient()
|
||||
|
||||
const event = {
|
||||
// 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)
|
||||
}
|
||||
|
||||
await client.publishEvent(event)
|
||||
// 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
|
||||
console.log('Stall publishing not yet implemented - needs private key signing')
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error publishing stall:', err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue