mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-10-01 17:31:13 +00:00
Compare commits
3 Commits
1105d39ca7
...
d419323f12
Author | SHA1 | Date | |
---|---|---|---|
|
d419323f12 | ||
|
940baae8a6 | ||
|
674ca9d7d7 |
@ -10,6 +10,7 @@
|
|||||||
.userInfo {
|
.userInfo {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
.userData {
|
.userData {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -117,7 +117,7 @@ const AuthoreSubscribe: Component<{
|
|||||||
fallback={<Loader />}
|
fallback={<Loader />}
|
||||||
>
|
>
|
||||||
<div class={styles.authorSubscribeCard}>
|
<div class={styles.authorSubscribeCard}>
|
||||||
<div class={styles.userInfo}>
|
<A href={`/p/${author()?.npub}`} class={styles.userInfo}>
|
||||||
<Avatar user={author()} size="ml" />
|
<Avatar user={author()} size="ml" />
|
||||||
<div class={styles.userData}>
|
<div class={styles.userData}>
|
||||||
<div class={styles.userName}>
|
<div class={styles.userName}>
|
||||||
@ -128,7 +128,7 @@ const AuthoreSubscribe: Component<{
|
|||||||
{author()?.nip05}
|
{author()?.nip05}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</A>
|
||||||
<div class={styles.userPitch}>
|
<div class={styles.userPitch}>
|
||||||
{author()?.about || ''}
|
{author()?.about || ''}
|
||||||
</div>
|
</div>
|
||||||
|
@ -98,70 +98,85 @@ const account = useAccountContext();
|
|||||||
|
|
||||||
const content = el.innerHTML;
|
const content = el.innerHTML;
|
||||||
|
|
||||||
const match = content.match(regex);
|
const tokens = content.split(regex);
|
||||||
|
|
||||||
if (match === null || match.length < 2) return el;
|
let items: any[] = [];
|
||||||
|
|
||||||
const [nostr, npub] = match;
|
for(let i=0; i<tokens.length; i++) {
|
||||||
|
const token = tokens[i];
|
||||||
|
|
||||||
if (npub.startsWith('npub')) {
|
|
||||||
|
|
||||||
const other = content.split(nostr);
|
if (token.startsWith('npub')) {
|
||||||
|
const id = npubToHex(token);
|
||||||
|
const user = (props.article?.mentionedUsers || {})[id];
|
||||||
|
|
||||||
const id = npubToHex(npub);
|
items.push(
|
||||||
|
|
||||||
return (
|
|
||||||
<p>
|
|
||||||
<span innerHTML={other[0] || ''}></span>
|
|
||||||
<Show
|
<Show
|
||||||
when={!props.article?.mentionedUsers || props.article.mentionedUsers[id] !== undefined}
|
when={user}
|
||||||
fallback={<A href={`/p/${npub}`}>{nostr}</A>}
|
fallback={<A href={`/p/${token}`}>nostr:{token}</A>}
|
||||||
>
|
>
|
||||||
<A href={`/p/${npub}`}>@{userName(props.article?.mentionedUsers ? props.article.mentionedUsers[id] : undefined)}</A>
|
<A href={`/p/${token}`}>@{userName(user)}</A>
|
||||||
</Show>
|
</Show>
|
||||||
<span innerHTML={other[1] || ''}></span>
|
);
|
||||||
</p>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (npub.startsWith('note')) {
|
continue;
|
||||||
const id = npubToHex(npub);
|
|
||||||
return (
|
|
||||||
<Show
|
|
||||||
when={!props.article?.mentionedNotes || props.article.mentionedNotes[id] !== undefined}
|
|
||||||
fallback={<A href={`/e/${npub}`}>{nostr}</A>}
|
|
||||||
>
|
|
||||||
<div class={styles.embeddedNote}>
|
|
||||||
<EmbeddedNote
|
|
||||||
class={styles.embeddedNote}
|
|
||||||
note={props.article?.mentionedNotes && props.article.mentionedNotes[id]}
|
|
||||||
mentionedUsers={props.article?.mentionedNotes && props.article.mentionedNotes[id].mentionedUsers || {}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (npub.startsWith('naddr')) {
|
|
||||||
const mention = props.article?.mentionedNotes && props.article.mentionedNotes[npub];
|
|
||||||
|
|
||||||
if (!mention) return el;
|
|
||||||
|
|
||||||
const preview = {
|
|
||||||
url: `/e/${npub}`,
|
|
||||||
description: (mention.post.tags.find(t => t[0] === 'summary') || [])[1] || mention.post.content.slice(0, 100),
|
|
||||||
images: [(mention.post.tags.find(t => t[0] === 'image') || [])[1] || mention.user.picture],
|
|
||||||
title: (mention.post.tags.find(t => t[0] === 'title') || [])[1] || authorName(mention.user),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('MENTION: ', mention)
|
if (token.startsWith('note')) {
|
||||||
return <ArticleLinkPreview
|
const id = npubToHex(token);
|
||||||
preview={preview}
|
const note = (props.article?.mentionedNotes || {})[id];
|
||||||
bordered={true}
|
|
||||||
/>;
|
items.push(
|
||||||
|
<Show
|
||||||
|
when={note}
|
||||||
|
fallback={<A href={`/e/${token}`}>nostr:{token}</A>}
|
||||||
|
>
|
||||||
|
<div class={styles.embeddedNote}>
|
||||||
|
<EmbeddedNote
|
||||||
|
class={styles.embeddedNote}
|
||||||
|
note={note}
|
||||||
|
mentionedUsers={note.mentionedUsers}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.startsWith('naddr')) {
|
||||||
|
const mention = props.article?.mentionedNotes && props.article.mentionedNotes[token];
|
||||||
|
|
||||||
|
if (!mention) {
|
||||||
|
items.push(<>nostr:{token}</>)
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
const preview = {
|
||||||
|
url: `/e/${token}`,
|
||||||
|
description: (mention.post.tags.find(t => t[0] === 'summary') || [])[1] || mention.post.content.slice(0, 100),
|
||||||
|
images: [(mention.post.tags.find(t => t[0] === 'image') || [])[1] || mention.user.picture],
|
||||||
|
title: (mention.post.tags.find(t => t[0] === 'title') || [])[1] || authorName(mention.user),
|
||||||
|
}
|
||||||
|
|
||||||
|
items.push(
|
||||||
|
<ArticleLinkPreview
|
||||||
|
preview={preview}
|
||||||
|
bordered={true}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const elem = document.createElement("span");
|
||||||
|
elem.innerHTML = token;
|
||||||
|
|
||||||
|
items.push(<>{elem}</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return el;
|
return <p><For each={items}>{item => <>{item}</>}</For></p>;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -715,17 +715,21 @@ const Longform: Component< { naddr: string } > = (props) => {
|
|||||||
|
|
||||||
let id = mention.id;
|
let id = mention.id;
|
||||||
|
|
||||||
|
updateStore('page', 'mentions',
|
||||||
|
(mentions) => ({ ...mentions, [id]: { ...mention } })
|
||||||
|
);
|
||||||
|
|
||||||
if (mention.kind === Kind.LongForm) {
|
if (mention.kind === Kind.LongForm) {
|
||||||
id = nip19.naddrEncode({
|
id = nip19.naddrEncode({
|
||||||
identifier: (mention.tags.find((t: string[]) => t[0] === 'd') || [])[1],
|
identifier: (mention.tags.find((t: string[]) => t[0] === 'd') || [])[1],
|
||||||
pubkey: mention.pubkey,
|
pubkey: mention.pubkey,
|
||||||
kind: mention.kind,
|
kind: mention.kind,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
updateStore('page', 'mentions',
|
updateStore('page', 'mentions',
|
||||||
(mentions) => ({ ...mentions, [id]: { ...mention } })
|
(mentions) => ({ ...mentions, [id]: { ...mention } })
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user