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