Fix links from profile about

This commit is contained in:
Bojan Mojsilovic 2024-03-27 17:16:19 +01:00
parent 8f5cd3b728
commit e10728f1c7
2 changed files with 10 additions and 9 deletions

View File

@ -10,6 +10,7 @@ import styles from "./MentionedUserLink.module.scss";
const MentionedUserLink: Component<{
user: PrimalUser,
npub?: string,
openInNewTab?: boolean,
id?: string,
}> = (props) => {
@ -39,7 +40,7 @@ const MentionedUserLink: Component<{
return <A
id={props.id}
class={styles.userMention}
href={`/p/${props.user.npub}`}
href={`/p/${props.user.npub || props.npub}`}
>
{p.children}
</A>;

View File

@ -1,7 +1,7 @@
import { A } from '@solidjs/router';
import { nip19 } from 'nostr-tools';
import { Component, createEffect, For, JSXElement, Show } from 'solid-js';
import { createStore } from 'solid-js/store';
import { Component, createEffect, For, JSXElement, onCleanup, Show } from 'solid-js';
import { createStore, reconcile } from 'solid-js/store';
import { APP_ID } from '../../App';
import { linebreakRegex, urlExtractRegex, specialCharsRegex, hashtagCharsRegex, profileRegexG, Kind } from '../../constants';
import { hexToNpub, npubToHex } from '../../lib/keys';
@ -179,8 +179,8 @@ const ProfileAbout: Component<{about: string | undefined }> = (props) => {
const label = user ? userName(user) : truncateNpub(npub);
return !user ?
<><A href={path}>@{label}</A>{end}</> :
<>{MentionedUserLink({ user })}{end}</>;
<><A href={path}>@{label}</A>{end}</> :
<>{MentionedUserLink({ user, npub })}{end}</>;
} catch (e) {
return <span class={styles.error}> {token}</span>;
}
@ -260,17 +260,17 @@ const ProfileAbout: Component<{about: string | undefined }> = (props) => {
});
getUserProfiles(userMentions, subId);
// const a = linkifyNostrNoteLink(linkifyNostrProfileLink(urlify(sanitize(about), () => '', false, false, true)));
// setRenderProfileAbout(a)
};
createEffect(() => {
if (props.about && props.about.length > 0) {
setAboutContent([]);
setAboutTokens([]);
setUsersMentionedInAbout(reconcile({}));
parseForMentions(props.about);
}
});
return (
<Show when={aboutContent.length > 0}>
<div class={styles.profileAbout}>