mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-10 23:47:12 +02:00
ui: show host first in members list, all relays in dropdown
- derivedParticipants now puts host first with 'host' role - Other participants from messages follow as 'member' - RelaysDropdown shows all NIP-53 liveActivity.relays
This commit is contained in:
@@ -399,18 +399,31 @@ export function ChatViewer({
|
||||
if (conversation?.type !== "live-chat" || !messages) {
|
||||
return conversation?.participants || [];
|
||||
}
|
||||
// Get unique pubkeys from messages
|
||||
const pubkeys = new Set<string>();
|
||||
|
||||
const hostPubkey = liveActivity?.hostPubkey;
|
||||
const participants: { pubkey: string; role: "host" | "member" }[] = [];
|
||||
|
||||
// Host always first
|
||||
if (hostPubkey) {
|
||||
participants.push({ pubkey: hostPubkey, role: "host" });
|
||||
}
|
||||
|
||||
// Add other participants from messages (excluding host)
|
||||
const seen = new Set(hostPubkey ? [hostPubkey] : []);
|
||||
for (const msg of messages) {
|
||||
if (msg.type !== "system") {
|
||||
pubkeys.add(msg.author);
|
||||
if (msg.type !== "system" && !seen.has(msg.author)) {
|
||||
seen.add(msg.author);
|
||||
participants.push({ pubkey: msg.author, role: "member" });
|
||||
}
|
||||
}
|
||||
return Array.from(pubkeys).map((pubkey) => ({
|
||||
pubkey,
|
||||
role: "member" as const,
|
||||
}));
|
||||
}, [conversation?.type, conversation?.participants, messages]);
|
||||
|
||||
return participants;
|
||||
}, [
|
||||
conversation?.type,
|
||||
conversation?.participants,
|
||||
messages,
|
||||
liveActivity?.hostPubkey,
|
||||
]);
|
||||
|
||||
if (!conversation) {
|
||||
return (
|
||||
|
||||
@@ -24,8 +24,15 @@ export function RelaysDropdown({ conversation }: RelaysDropdownProps) {
|
||||
// Get relays for this conversation
|
||||
const relays: string[] = [];
|
||||
|
||||
// NIP-29: Single group relay
|
||||
if (conversation.metadata?.relayUrl) {
|
||||
// NIP-53: Multiple relays from liveActivity
|
||||
const liveActivityRelays = conversation.metadata?.liveActivity?.relays as
|
||||
| string[]
|
||||
| undefined;
|
||||
if (liveActivityRelays?.length) {
|
||||
relays.push(...liveActivityRelays);
|
||||
}
|
||||
// NIP-29: Single group relay (fallback)
|
||||
else if (conversation.metadata?.relayUrl) {
|
||||
relays.push(conversation.metadata.relayUrl);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user