mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-08 05:39:52 +02:00
fix: reconstruct chat command for edit button
Add chat case to reconstructCommand to properly reconstruct the chat command string when clicking the edit button in the window toolbar. - NIP-29 groups: reconstruct as `chat relay'group-id` - NIP-53 live activities: reconstruct as `chat naddr1...`
This commit is contained in:
@@ -96,6 +96,49 @@ export function reconstructCommand(window: WindowInstance): string {
|
|||||||
case "debug":
|
case "debug":
|
||||||
return "debug";
|
return "debug";
|
||||||
|
|
||||||
|
case "chat": {
|
||||||
|
// Reconstruct chat command from protocol and identifier
|
||||||
|
const { protocol, identifier } = props;
|
||||||
|
|
||||||
|
if (!identifier) {
|
||||||
|
return "chat";
|
||||||
|
}
|
||||||
|
|
||||||
|
// NIP-29 relay groups: chat relay'group-id
|
||||||
|
if (protocol === "nip-29" && identifier.type === "group") {
|
||||||
|
const relayUrl = identifier.relays?.[0] || "";
|
||||||
|
const groupId = identifier.value;
|
||||||
|
|
||||||
|
if (relayUrl && groupId) {
|
||||||
|
// Strip wss:// prefix for cleaner command
|
||||||
|
const cleanRelay = relayUrl.replace(/^wss?:\/\//, "");
|
||||||
|
return `chat ${cleanRelay}'${groupId}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NIP-53 live activities: chat naddr1...
|
||||||
|
if (protocol === "nip-53" && identifier.type === "live-activity") {
|
||||||
|
const { pubkey, identifier: dTag } = identifier.value || {};
|
||||||
|
const relays = identifier.relays;
|
||||||
|
|
||||||
|
if (pubkey && dTag) {
|
||||||
|
try {
|
||||||
|
const naddr = nip19.naddrEncode({
|
||||||
|
kind: 30311,
|
||||||
|
pubkey,
|
||||||
|
identifier: dTag,
|
||||||
|
relays,
|
||||||
|
});
|
||||||
|
return `chat ${naddr}`;
|
||||||
|
} catch {
|
||||||
|
// Fallback if encoding fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "chat";
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return appId; // Fallback to just the command name
|
return appId; // Fallback to just the command name
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user