Skip to content

Commit 09f470f

Browse files
committed
wip
1 parent b60f139 commit 09f470f

20 files changed

Lines changed: 198 additions & 206 deletions

app/src/components/Association/FavoriteAssociation.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
type ReplyMessageSchema,
66
type MarkdownMessageSchema,
77
type User,
8-
MediaMessageSchema
8+
MediaMessageSchema,
9+
UserProfile
910
} from '@concrnt/worldlib'
1011
import { ContentWithCCAvatar } from '../ContentWithCCAvatar'
1112
import { Box, IconButton, Link, ListItemIcon, ListItemText, Menu, MenuItem, Typography } from '@mui/material'
@@ -37,14 +38,11 @@ export const FavoriteAssociation = (props: FavoriteAssociationProps): JSX.Elemen
3738
> | null>(null)
3839
const isMeToOther = props.association?.authorUser?.ccid !== props.perspective
3940

40-
const Nominative =
41-
props.association.document.body.profileOverride?.username ??
42-
props.association?.authorUser?.profile?.username ??
43-
'anonymous'
44-
const Possessive =
45-
(target?.document.body.profileOverride?.username ?? target?.authorUser?.profile?.username ?? 'anonymous') + "'s"
41+
const Nominative = props.association?.authorProfile.username ?? 'anonymous'
42+
const Possessive = (target?.authorProfile.username ?? 'anonymous') + "'s"
4643

4744
const actionUser: User | undefined = isMeToOther ? props.association.authorUser : target?.authorUser
45+
const actionUserProfile: UserProfile = isMeToOther ? props.association.authorProfile : target?.authorProfile!
4846
const [menuAnchor, setMenuAnchor] = useState<null | HTMLElement>(null)
4947

5048
const masked =
@@ -57,13 +55,7 @@ export const FavoriteAssociation = (props: FavoriteAssociationProps): JSX.Elemen
5755
}, [props.association])
5856

5957
return (
60-
<ContentWithCCAvatar
61-
author={actionUser}
62-
linkTo={targetLink}
63-
profileOverride={
64-
isMeToOther ? props.association.document.body.profileOverride : target?.document.body.profileOverride
65-
}
66-
>
58+
<ContentWithCCAvatar author={actionUser} linkTo={targetLink} profile={actionUserProfile}>
6759
<Box display="flex" justifyContent="space-between" alignItems="center">
6860
<Box display="flex" overflow="hidden">
6961
<Box display="flex" alignItems="center" flexShrink={0} gap={0.5}>

app/src/components/Association/MentionAssociation.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
type Message,
55
type ReplyMessageSchema,
66
type MarkdownMessageSchema,
7-
type User
7+
type User,
8+
UserProfile
89
} from '@concrnt/worldlib'
910
import { ContentWithCCAvatar } from '../ContentWithCCAvatar'
1011
import { Box, Typography } from '@mui/material'
@@ -22,23 +23,19 @@ export const MentionAssociation = (props: MentionAssociationProps): ReactElement
2223
const [target, setTarget] = useState<Message<MarkdownMessageSchema | ReplyMessageSchema> | null>(null)
2324
const isMeToOther = props.association?.authorUser?.ccid !== props.perspective
2425

25-
const Nominative = props.association?.authorUser?.profile?.username ?? 'anonymous'
26-
const Possessive =
27-
(target?.document.body.profileOverride?.username ?? target?.authorUser?.profile?.username ?? 'anonymous') + "'s"
26+
const Nominative = props.association?.authorProfile.username ?? 'anonymous'
27+
const Possessive = (target?.authorProfile.username ?? 'anonymous') + "'s"
2828

2929
const actionUser: User | undefined = isMeToOther ? props.association.authorUser : target?.authorUser
30+
const actionUserProfile: UserProfile = isMeToOther ? props.association.authorProfile : target?.authorProfile!
3031

3132
const targetLink = target ? `/${target.author}/${target.id}` : '#' // Link to mention message
3233
useEffect(() => {
3334
props.association.getTargetMessage().then(setTarget)
3435
}, [props.association])
3536

3637
return (
37-
<ContentWithCCAvatar
38-
author={actionUser}
39-
linkTo={targetLink}
40-
profileOverride={!isMeToOther ? target?.document.body.profileOverride : undefined}
41-
>
38+
<ContentWithCCAvatar author={actionUser} linkTo={targetLink} profile={actionUserProfile}>
4239
<Box display="flex" justifyContent="space-between">
4340
<Typography>
4441
{isMeToOther ? (

app/src/components/Association/ReactionAssociation.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
type ReplyMessageSchema,
66
type MarkdownMessageSchema,
77
type User,
8-
MediaMessageSchema
8+
MediaMessageSchema,
9+
UserProfile
910
} from '@concrnt/worldlib'
1011
import { ContentWithCCAvatar } from '../ContentWithCCAvatar'
1112
import { Box, IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Typography } from '@mui/material'
@@ -36,14 +37,12 @@ export const ReactionAssociation = (props: ReactionAssociationProps): JSX.Elemen
3637
> | null>(null)
3738
const isMeToOther = props.association?.authorUser?.ccid !== props.perspective
3839

39-
const Nominative =
40-
props.association.document.body.profileOverride?.username ??
41-
props.association?.authorUser?.profile?.username ??
42-
'anonymous'
43-
const Possessive =
44-
(target?.document.body.profileOverride?.username ?? target?.authorUser?.profile?.username ?? 'anonymous') + "'s"
40+
const Nominative = props.association?.authorProfile.username ?? 'anonymous'
41+
const Possessive = (target?.authorProfile.username ?? 'anonymous') + "'s"
4542

4643
const actionUser: User | undefined = isMeToOther ? props.association.authorUser : target?.authorUser
44+
const actionUserProfile: UserProfile = isMeToOther ? props.association.authorProfile : target?.authorProfile!
45+
4746
const [menuAnchor, setMenuAnchor] = useState<null | HTMLElement>(null)
4847

4948
const masked =
@@ -56,13 +55,7 @@ export const ReactionAssociation = (props: ReactionAssociationProps): JSX.Elemen
5655
}, [props.association])
5756

5857
return (
59-
<ContentWithCCAvatar
60-
author={actionUser}
61-
linkTo={targetLink}
62-
profileOverride={
63-
isMeToOther ? props.association.document.body.profileOverride : target?.document.body.profileOverride
64-
}
65-
>
58+
<ContentWithCCAvatar author={actionUser} linkTo={targetLink} profile={actionUserProfile}>
6659
<Box display="flex" justifyContent="space-between" alignItems="center">
6760
<Box display="flex" overflow="hidden">
6861
<Box display="flex" alignItems="center" flexShrink={0} gap={0.5}>

app/src/components/Association/ReadAccessAssociation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ export const ReadAccessAssociation = (props: ReadAccessAssociationProps): ReactE
2222
}, [props.association])
2323

2424
return (
25-
<ContentWithCCAvatar author={props.association.authorUser}>
25+
<ContentWithCCAvatar author={props.association.authorUser} profile={props.association.authorProfile}>
2626
<Box display="flex" justifyContent="space-between">
2727
<Typography>
2828
<Trans
2929
i18nKey="pages.associations.readAccessRequest"
3030
components={{
3131
username: (
3232
<CCLink to={`/${props.association.author}`}>
33-
{props.association.authorUser?.profile?.username}
33+
{props.association.authorProfile.username}
3434
</CCLink>
3535
),
3636
timeline: (

app/src/components/ContentWithCCAvatar.tsx

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import {
2+
User,
23
type MarkdownMessageSchema,
34
type Message,
45
type ReplyMessageSchema,
5-
type ProfileSchema,
6-
type User,
7-
type ProfileOverride
6+
type UserProfile
87
} from '@concrnt/worldlib'
98
import { Box, IconButton, ListItem, type SxProps } from '@mui/material'
109
import { Link as routerLink, useNavigate, useLocation } from 'react-router-dom'
@@ -16,9 +15,7 @@ export interface ContentWithCCAvatarProps {
1615
message?: Message<MarkdownMessageSchema | ReplyMessageSchema>
1716
linkTo?: string
1817
author?: User
19-
profileOverride?: ProfileOverride
20-
characterOverride?: ProfileSchema
21-
avatarOverride?: string
18+
profile: UserProfile
2219
children?: JSX.Element | Array<JSX.Element | undefined>
2320
sx?: SxProps
2421
apId?: string
@@ -37,16 +34,14 @@ export const ContentWithCCAvatar = (props: ContentWithCCAvatarProps): JSX.Elemen
3734
return (
3835
<>
3936
<Box itemProp="author" itemScope itemType="https://schema.org/Person">
40-
{props.author && (
37+
<>
38+
<meta itemProp="identifier" content={props.profile.ccid} />
39+
<meta itemProp="url" content={'https://concrnt.world/' + props.profile.ccid} />
40+
</>
41+
{props.profile.alias && <meta itemProp="alternateName" content={props.profile.alias} />}
42+
{props.profile.username && (
4143
<>
42-
<meta itemProp="identifier" content={props.author.ccid} />
43-
<meta itemProp="url" content={'https://concrnt.world/' + props.author.ccid} />
44-
</>
45-
)}
46-
{props.author?.alias && <meta itemProp="alternateName" content={props.author.alias} />}
47-
{props.author?.profile?.username && (
48-
<>
49-
<meta itemProp="name" content={props.author.profile.username} />
44+
<meta itemProp="name" content={props.profile.username} />
5045
</>
5146
)}
5247
</Box>
@@ -73,11 +68,7 @@ export const ContentWithCCAvatar = (props: ContentWithCCAvatarProps): JSX.Elemen
7368
e.stopPropagation() // prevent to navigate other page
7469
}}
7570
>
76-
<ProfileTooltip
77-
user={props.author}
78-
subProfileID={props.profileOverride?.profileID}
79-
profileOverride={props.profileOverride}
80-
>
71+
<ProfileTooltip user={props.author} profile={props.profile}>
8172
<IconButton
8273
sx={{
8374
width: { xs: '38px', sm: '48px' },
@@ -88,15 +79,14 @@ export const ContentWithCCAvatar = (props: ContentWithCCAvatarProps): JSX.Elemen
8879
to={
8980
apLink ??
9081
'/' +
91-
(props.author?.ccid ?? '') +
92-
(props.profileOverride?.profileID ? '#' + props.profileOverride.profileID : '')
82+
(props.profile.ccid ?? '') +
83+
(props.profile.profileOverrideID ? '#' + props.profile.profileOverrideID : '')
9384
}
9485
onPointerDown={() => profile.forceClose()} // prevent to stick showing when clicking
9586
>
9687
<CCAvatar
97-
avatarURL={props.author?.profile?.avatar}
98-
avatarOverride={props.avatarOverride || props.profileOverride?.avatar}
99-
identiconSource={props.author?.ccid ?? ''}
88+
avatarURL={props.profile.avatar}
89+
identiconSource={props.profile.ccid}
10090
sx={{
10191
width: { xs: '38px', sm: '48px' },
10292
height: { xs: '38px', sm: '48px' }

app/src/components/Message/MessageViewBase.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ export const MessageViewBase = (props: MessageViewProps): JSX.Element => {
7171
return (
7272
<ContentWithCCAvatar
7373
message={props.message}
74+
profile={props.message.authorProfile}
7475
author={props.message.authorUser}
75-
profileOverride={props.message.document.body.profileOverride}
76-
avatarOverride={characterOverride?.parsedDoc.body.avatar}
77-
characterOverride={characterOverride?.parsedDoc.body}
7876
apId={apId}
7977
>
8078
<MessageHeader

app/src/components/Message/OneLineMessageView.tsx

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,16 @@ import { CCAvatar } from '../ui/CCAvatar'
44
import { TimeDiff } from '../ui/TimeDiff'
55
import { type Message, type ReplyMessageSchema, type MarkdownMessageSchema } from '@concrnt/worldlib'
66
import { CfmRendererLite } from '../ui/CfmRendererLite'
7-
import { useEffect, useState } from 'react'
8-
import { useClient } from '../../context/ClientContext'
97
import { CCLink } from '../ui/CCLink'
10-
import { Profile } from '@concrnt/client'
118
import { CfmRenderer } from '../ui/CfmRenderer'
129

1310
export interface OneLineMessageViewProps {
1411
message: Message<MarkdownMessageSchema | ReplyMessageSchema>
1512
}
1613

1714
export const OneLineMessageView = (props: OneLineMessageViewProps): JSX.Element => {
18-
const { client } = useClient()
19-
20-
const [characterOverride, setProfileOverride] = useState<Profile<any> | undefined>(undefined)
21-
2215
const externalLink = props.message.document.meta?.apObjectRef // Link to external message
2316

24-
useEffect(() => {
25-
if (!(client && props.message.document.body.profileOverride?.profileID)) return
26-
client.api
27-
.getProfile(props.message.document.body.profileOverride?.profileID, props.message.author)
28-
.then((profile) => {
29-
setProfileOverride(profile ?? undefined)
30-
})
31-
}, [client, props.message])
32-
3317
return (
3418
<Box
3519
sx={{
@@ -50,12 +34,9 @@ export const OneLineMessageView = (props: OneLineMessageViewProps): JSX.Element
5034
to={'/' + props.message.author}
5135
>
5236
<CCAvatar
53-
alt={props.message.authorUser?.profile?.username}
54-
avatarURL={props.message.authorUser?.profile?.avatar}
55-
identiconSource={props.message.author}
56-
avatarOverride={
57-
characterOverride?.parsedDoc.body.avatar ?? props.message.document.body.profileOverride?.avatar
58-
}
37+
alt={props.message.authorProfile.username}
38+
avatarURL={props.message.authorProfile.avatar}
39+
identiconSource={props.message.authorProfile.ccid}
5940
sx={{
6041
width: { xs: '38px', sm: '48px' },
6142
height: { xs: '12px', sm: '18px' }

app/src/components/NotificationTimeline.tsx

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,7 @@ const SummarisedLike = (props: { items: Association<any>[] }) => {
411411
>
412412
<CCAvatar
413413
circle
414-
avatarURL={
415-
item.document.body.profileOverride?.avatar ?? item.authorUser?.profile?.avatar
416-
}
414+
avatarURL={item.authorProfile.avatar}
417415
sx={{
418416
width: { width: '32px', height: '32px' }
419417
}}
@@ -425,17 +423,13 @@ const SummarisedLike = (props: { items: Association<any>[] }) => {
425423
{props.items.length === 1 ? (
426424
<Typography>
427425
{t('favorite', {
428-
name:
429-
props.items[0].document.body.profileOverride?.username ??
430-
props.items[0].authorUser?.profile?.username
426+
name: props.items[0].authorProfile.username
431427
})}
432428
</Typography>
433429
) : (
434430
<Typography>
435431
{t('favoriteMany', {
436-
name:
437-
props.items[0].document.body.profileOverride?.username ??
438-
props.items[0].authorUser?.profile?.username,
432+
name: props.items[0].authorProfile.username,
439433
count: props.items.length - 1
440434
})}
441435
</Typography>
@@ -468,7 +462,6 @@ const SummarisedReaction = (props: { items: Association<any>[] }) => {
468462

469463
const reactions: Record<string, Association<any>[]> = {}
470464
for (const item of props.items) {
471-
if (!item.authorUser) continue
472465
if (item.variant in reactions) {
473466
reactions[item.variant].push(item)
474467
} else {
@@ -549,10 +542,7 @@ const SummarisedReaction = (props: { items: Association<any>[] }) => {
549542
>
550543
<CCAvatar
551544
circle
552-
avatarURL={
553-
item.document.body.profileOverride?.avatar ??
554-
item.authorUser?.profile?.avatar
555-
}
545+
avatarURL={item.authorProfile.avatar}
556546
sx={{
557547
width: { width: '32px', height: '32px' }
558548
}}
@@ -569,17 +559,13 @@ const SummarisedReaction = (props: { items: Association<any>[] }) => {
569559
{props.items.length === 1 ? (
570560
<Typography>
571561
{t('reaction', {
572-
name:
573-
props.items[0].document.body.profileOverride?.username ??
574-
props.items[0].authorUser?.profile?.username
562+
name: props.items[0].authorProfile.username
575563
})}
576564
</Typography>
577565
) : (
578566
<Typography>
579567
{t('reactionMany', {
580-
name:
581-
props.items[0].document.body.profileOverride?.username ??
582-
props.items[0].authorUser?.profile?.username,
568+
name: props.items[0].authorProfile.username,
583569
count: props.items.length - 1
584570
})}
585571
</Typography>

app/src/components/Profile.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ export function Profile(props: ProfileProps): JSX.Element {
201201
isLoading={!props.user}
202202
alt={props.user.profile?.username}
203203
avatarURL={props.user.profile?.avatar}
204-
avatarOverride={subProfile ? subProfile.parsedDoc.body.avatar : undefined}
205204
identiconSource={props.user.ccid}
206205
sx={{
207206
width: '100px',

app/src/components/RealtimeTimeline.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,7 @@ const timeline = forwardRef((props: RealtimeTimelineProps, ref: ForwardedRef<VLi
145145
.getMessage<Messages>(item.resourceID, item.owner, item.timelineID.split('@')[1])
146146
.then(async (msg) => {
147147
if (!msg) return
148-
let icon = undefined
149-
if (msg.document.body.profileOverride?.profileID) {
150-
icon = await client.api
151-
.getProfile<any>(msg.document.body.profileOverride?.profileID, item.owner)
152-
.then((p) => p?.parsedDoc.body.avatar)
153-
} else if (msg.document.body.profileOverride?.avatar) {
154-
icon = msg.document.body.profileOverride?.avatar
155-
} else {
156-
icon = msg.authorUser?.profile?.avatar
157-
}
148+
let icon = msg.authorProfile.avatar
158149
setNewArrivals((prev) => {
159150
if (isCancelled) return prev
160151
if (!icon) return prev

0 commit comments

Comments
 (0)