Fix people list

This commit is contained in:
Bojan Mojsilovic 2024-04-19 15:36:12 +02:00
parent 28c1d6dca7
commit de0cdd6c09
5 changed files with 24 additions and 48 deletions

View File

@ -13,6 +13,7 @@ import styles from './PeopleList.module.scss';
const MentionedPerson: Component<{ const MentionedPerson: Component<{
person: PrimalUser, person: PrimalUser,
id?: string, id?: string,
noAbout?: boolean,
}> = (props) => { }> = (props) => {
const account = useAccountContext(); const account = useAccountContext();
@ -44,9 +45,11 @@ const MentionedPerson: Component<{
</Show> </Show>
</div> </div>
<div class={styles.about}> <Show when={!props.noAbout}>
{props.person.about || ''} <div class={styles.about}>
</div> {props.person.about || ''}
</div>
</Show>
</A> </A>
); );
} }

View File

@ -76,23 +76,21 @@
.peopleList { .peopleList {
margin-bottom: 16px; margin-bottom: 16px;
display: grid; display: flex;
grid-template-columns: 52px 148px 72px; gap: 8px;
grid-template-rows: 1fr;
grid-template-areas: "avatar content follow";
grid-column-gap: 14px;
text-decoration: none; text-decoration: none;
align-items: center; align-items: center;
width: 300px;
.avatar { .avatar {
grid-area: avatar; grid-area: avatar;
display: grid; display: grid;
justify-items: center; justify-items: center;
height: 52px; height: 44px;
.avatarImg { .avatarImg {
width: 52px; width: 44px;
height: 52px; height: 44px;
border-radius: 50%; border-radius: 50%;
} }
} }
@ -101,13 +99,16 @@
grid-area: content; grid-area: content;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: center;
gap: 4px;
flex-grow: 1;
.name { .name {
color: var(--text-primary); color: var(--text-primary);
font-size: 16px; font-size: 16px;
font-weight: 700; font-weight: 700;
line-height: 16px; line-height: 16px;
max-width: 168px;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;

View File

@ -1,11 +1,7 @@
import { A } from '@solidjs/router'; import { Component, Show } from 'solid-js';
import { Component, For, Show } from 'solid-js';
import { useAccountContext } from '../../contexts/AccountContext'; import { useAccountContext } from '../../contexts/AccountContext';
import { hookForDev } from '../../lib/devTools'; import { hookForDev } from '../../lib/devTools';
import { authorName, nip05Verification, truncateNpub } from '../../stores/profile';
import { PrimalNote, PrimalUser } from '../../types/primal'; import { PrimalNote, PrimalUser } from '../../types/primal';
import Avatar from '../Avatar/Avatar';
import FollowButton from '../FollowButton/FollowButton';
import MentionedPeople from './MentionedPeople'; import MentionedPeople from './MentionedPeople';
import styles from './PeopleList.module.scss'; import styles from './PeopleList.module.scss';
@ -19,8 +15,6 @@ const PeopleList: Component<{
id?: string, id?: string,
note?: PrimalNote, note?: PrimalNote,
}> = (props) => { }> = (props) => {
const account = useAccountContext();
const author = () => props.note?.user; const author = () => props.note?.user;
const mentioned = () => { const mentioned = () => {

View File

@ -6,6 +6,7 @@ import { authorName, nip05Verification, truncateNpub } from '../../stores/profil
import { PrimalNote, PrimalUser } from '../../types/primal'; import { PrimalNote, PrimalUser } from '../../types/primal';
import Avatar from '../Avatar/Avatar'; import Avatar from '../Avatar/Avatar';
import FollowButton from '../FollowButton/FollowButton'; import FollowButton from '../FollowButton/FollowButton';
import MentionedPerson from './MentionedPerson';
import styles from './PeopleList.module.scss'; import styles from './PeopleList.module.scss';
@ -25,33 +26,7 @@ const Repliers: Component<{
<div id="trending_section" class={styles.trendingSection}> <div id="trending_section" class={styles.trendingSection}>
<For each={people()}> <For each={people()}>
{ {
(person) => (person) => <MentionedPerson person={person} noAbout={true} />
<A href={`/p/${person?.npub}`} class={styles.peopleList}>
<div class={styles.avatar}>
<Avatar
size="md"
user={person}
/>
</div>
<div class={styles.content}>
<div class={styles.name}>
{authorName(person)}
</div>
<div class={styles.verification} title={person?.nip05}>
<Show when={person?.nip05}>
<span
class={styles.verifiedBy}
title={person?.nip05}
>
{nip05Verification(person)}
</span>
</Show>
</div>
</div>
<Show when={account?.publicKey !== person.pubkey || !account?.following.includes(person.pubkey)}>
<FollowButton person={person} />
</Show>
</A>
} }
</For> </For>
</div> </div>

View File

@ -2,7 +2,7 @@ import { Component, createEffect, createMemo, For, onCleanup, onMount, Show } fr
import Note from '../components/Note/Note'; import Note from '../components/Note/Note';
import styles from './Thread.module.scss'; import styles from './Thread.module.scss';
import { useNavigate, useParams } from '@solidjs/router'; import { useNavigate, useParams } from '@solidjs/router';
import { PrimalNote, SendNoteResult } from '../types/primal'; import { PrimalNote, PrimalUser, SendNoteResult } from '../types/primal';
import PeopleList from '../components/PeopleList/PeopleList'; import PeopleList from '../components/PeopleList/PeopleList';
import ReplyToNote from '../components/ReplyToNote/ReplyToNote'; import ReplyToNote from '../components/ReplyToNote/ReplyToNote';
@ -19,6 +19,7 @@ import PageTitle from '../components/PageTitle/PageTitle';
import NavHeader from '../components/NavHeader/NavHeader'; import NavHeader from '../components/NavHeader/NavHeader';
import Loader from '../components/Loader/Loader'; import Loader from '../components/Loader/Loader';
import { isIOS } from '../components/BannerIOS/BannerIOS'; import { isIOS } from '../components/BannerIOS/BannerIOS';
import { unwrap } from 'solid-js/store';
const Thread: Component = () => { const Thread: Component = () => {
@ -91,7 +92,9 @@ const Thread: Component = () => {
}; };
const people = () => { const people = () => {
const authors = (threadContext?.notes || []).map(n => n.user); const authors = (threadContext?.notes || []).
reduce<PrimalUser[]>((acc, n) => acc.find(u => u.pubkey === n.user.pubkey) ? [...acc] : [ ...acc, { ...n.user }], []);
const mentions = Object.values(primaryNote()?.mentionedUsers || {}). const mentions = Object.values(primaryNote()?.mentionedUsers || {}).
filter((u) => !authors.find(a => u.pubkey === a.pubkey)); filter((u) => !authors.find(a => u.pubkey === a.pubkey));