mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
ensure unique ids for dom
This commit is contained in:
1 parent
15ec6c69e7
commit
381fdaf977
1 file changed
+15
-7
@@ -372,6 +372,7 @@ export function DMProvider({ children, protocolMode = PROTOCOL_MODE.NIP17_ONLY,
|
|||||||
const { decryptedContent, error } = await decryptNIP4Message(msg, otherPubkey);
|
const { decryptedContent, error } = await decryptNIP4Message(msg, otherPubkey);
|
||||||
return {
|
return {
|
||||||
...msg,
|
...msg,
|
||||||
|
id: msg.id || `missing-nip4-${msg.created_at}-${msg.pubkey.substring(0, 8)}-${msg.content.substring(0, 16)}`,
|
||||||
content: msg.content,
|
content: msg.content,
|
||||||
decryptedContent: decryptedContent,
|
decryptedContent: decryptedContent,
|
||||||
error: error,
|
error: error,
|
||||||
@@ -390,10 +391,16 @@ export function DMProvider({ children, protocolMode = PROTOCOL_MODE.NIP17_ONLY,
|
|||||||
// These messages were saved without the gift wrap, but the content IS the decrypted text
|
// These messages were saved without the gift wrap, but the content IS the decrypted text
|
||||||
return {
|
return {
|
||||||
...msg,
|
...msg,
|
||||||
|
// Ensure unique ID even if two messages sent in same second
|
||||||
|
id: msg.id || `missing-${msg.created_at}-${msg.pubkey.substring(0, 8)}-${msg.content.substring(0, 16)}`,
|
||||||
decryptedContent: msg.content, // Content is already decrypted in old format
|
decryptedContent: msg.content, // Content is already decrypted in old format
|
||||||
} as NostrEvent & { decryptedContent?: string; error?: string };
|
} as NostrEvent & { decryptedContent?: string; error?: string };
|
||||||
}
|
}
|
||||||
return msg;
|
// Final fallback: ensure all messages have unique IDs
|
||||||
|
return {
|
||||||
|
...msg,
|
||||||
|
id: msg.id || `missing-${msg.kind}-${msg.created_at}-${msg.pubkey.substring(0, 8)}-${msg.content?.substring(0, 16) || 'nocontent'}`,
|
||||||
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
newState.set(participantPubkey, {
|
newState.set(participantPubkey, {
|
||||||
@@ -774,16 +781,17 @@ export function DMProvider({ children, protocolMode = PROTOCOL_MODE.NIP17_ONLY,
|
|||||||
conversationPartner = sealEvent.pubkey;
|
conversationPartner = sealEvent.pubkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[DM] ✅ NIP-17 message processed successfully`, {
|
// console.log(`[DM] ✅ NIP-17 message processed successfully`, {
|
||||||
giftWrapId: event.id,
|
// giftWrapId: event.id,
|
||||||
innerKind: messageEvent.kind, // 14 for text, 15 for files
|
// innerKind: messageEvent.kind, // 14 for text, 15 for files
|
||||||
messageId: messageEvent.id,
|
// messageId: messageEvent.id,
|
||||||
conversationPartner,
|
// conversationPartner,
|
||||||
});
|
// });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
processedMessage: {
|
processedMessage: {
|
||||||
...messageEvent,
|
...messageEvent,
|
||||||
|
id: messageEvent.id || `missing-nip17-inner-${messageEvent.created_at}-${messageEvent.pubkey.substring(0, 8)}-${messageEvent.content.substring(0, 16)}`,
|
||||||
content: event.content,
|
content: event.content,
|
||||||
decryptedContent: messageEvent.content,
|
decryptedContent: messageEvent.content,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user