Skip to content

Commit 54df4cf

Browse files
committed
wip2
1 parent 09f470f commit 54df4cf

7 files changed

Lines changed: 16 additions & 65 deletions

File tree

app/src/components/Association/FavoriteAssociation.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ export const FavoriteAssociation = (props: FavoriteAssociationProps): JSX.Elemen
4646
const [menuAnchor, setMenuAnchor] = useState<null | HTMLElement>(null)
4747

4848
const masked =
49-
(isMeToOther ? props.association.document.body.profileOverride : target?.document.body.profileOverride) !==
50-
undefined
49+
(isMeToOther ? props.association.authorProfile.original : target?.authorProfile.original) !== undefined
5150

5251
const targetLink = target ? `/${target.author}/${target.id}` : '#' // Link to favorite message
5352
useEffect(() => {

app/src/components/Association/ReactionAssociation.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ export const ReactionAssociation = (props: ReactionAssociationProps): JSX.Elemen
4646
const [menuAnchor, setMenuAnchor] = useState<null | HTMLElement>(null)
4747

4848
const masked =
49-
(isMeToOther ? props.association.document.body.profileOverride : target?.document.body.profileOverride) !==
50-
undefined
49+
(isMeToOther ? props.association.authorProfile.original : target?.authorProfile.original) !== undefined
5150

5251
const targetLink = target ? `/${target.author}/${target.id}` : '#' // Link to reacted message
5352
useEffect(() => {

app/src/components/Message/MessageActions.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ export const MessageActions = (props: MessageActionsProps): JSX.Element => {
148148
height: '20px',
149149
width: '20px'
150150
}}
151-
avatarURL={
152-
fav.document.body.profileOverride?.avatar ?? fav.authorUser?.profile?.avatar
153-
}
151+
avatarURL={fav.authorProfile.avatar}
154152
identiconSource={fav.author}
155153
/>
156154
<Typography
@@ -159,9 +157,7 @@ export const MessageActions = (props: MessageActionsProps): JSX.Element => {
159157
color: '#fff'
160158
}}
161159
>
162-
{fav.document.body.profileOverride?.username ||
163-
fav.authorUser?.profile?.username ||
164-
'anonymous'}
160+
{fav.authorProfile.username ?? 'anonymous'}
165161
</Typography>
166162
</Box>
167163
))}

app/src/components/Message/MessageHeader.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { useTranslation } from 'react-i18next'
1515

1616
export interface MessageHeaderProps {
1717
message: Message<MarkdownMessageSchema | ReplyMessageSchema>
18-
usernameOverride?: string
1918
additionalMenuItems?: JSX.Element | JSX.Element[]
2019
timeLink?: string
2120
}
@@ -64,10 +63,7 @@ export const MessageHeader = (props: MessageHeaderProps): JSX.Element => {
6463
fontSize: { xs: '0.9rem', sm: '0.95rem' }
6564
}}
6665
>
67-
{props.usernameOverride ||
68-
props.message.document.body.profileOverride?.username ||
69-
props.message.authorUser?.profile?.username ||
70-
'anonymous'}
66+
{props.message.authorProfile.username || 'anonymous'}
7167
</Typography>
7268
</CCLink>
7369
{props.message.document.body.profileOverride &&

app/src/components/Message/MessageReactions.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ export const MessageReactions = (props: MessageReactionsProps): JSX.Element => {
154154
to={'/' + reaction.reaction.author}
155155
>
156156
<CCAvatar
157-
avatarURL={reaction.reaction.authorUser?.profile?.avatar}
158-
identiconSource={reaction.reaction.author}
157+
avatarURL={reaction.reaction.authorProfile.avatar}
158+
identiconSource={reaction.reaction.authorProfile.ccid}
159159
sx={{
160160
width: { xs: '12px', sm: '18px' },
161161
height: { xs: '12px', sm: '18px' }
@@ -167,7 +167,7 @@ export const MessageReactions = (props: MessageReactionsProps): JSX.Element => {
167167
color: '#fff'
168168
}}
169169
>
170-
{reaction.reaction.authorUser?.profile?.username || 'anonymous'}
170+
{reaction.reaction.authorProfile.username || 'anonymous'}
171171
</Typography>
172172
</Box>
173173
</Box>
@@ -236,10 +236,7 @@ export const MessageReactions = (props: MessageReactionsProps): JSX.Element => {
236236
}}
237237
>
238238
<CCAvatar
239-
avatarURL={
240-
reaction.document.body.profileOverride?.avatar ??
241-
reaction.authorUser?.profile?.avatar
242-
}
239+
avatarURL={reaction.authorProfile.avatar}
243240
identiconSource={reaction.author}
244241
sx={{
245242
width: { xs: '12px', sm: '18px' },
@@ -252,9 +249,7 @@ export const MessageReactions = (props: MessageReactionsProps): JSX.Element => {
252249
color: '#fff'
253250
}}
254251
>
255-
{reaction.document.body.profileOverride?.username ||
256-
reaction.authorUser?.profile?.username ||
257-
'anonymous'}
252+
{reaction.authorProfile.username || 'anonymous'}
258253
</Typography>
259254
</Box>
260255
))}

app/src/components/Message/MessageViewBase.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ import { MessageHeader } from './MessageHeader'
33
import { MessageActions } from './MessageActions'
44
import { MessageReactions } from './MessageReactions'
55
import { type RerouteMessageSchema, type Message, Schemas } from '@concrnt/worldlib'
6-
import { Profile } from '@concrnt/client'
76
import { PostedTimelines } from './PostedTimelines'
87
import { ContentWithCCAvatar } from '../ContentWithCCAvatar'
98
import ArrowForwardIcon from '@mui/icons-material/ArrowForward'
109
import ReplayIcon from '@mui/icons-material/Replay'
11-
import { useEffect, useMemo, useState } from 'react'
12-
import { useClient } from '../../context/ClientContext'
10+
import { useMemo, useState } from 'react'
1311
import { AutoSummaryProvider } from '../../context/AutoSummaryContext'
1412
import { useTranslator } from '../../context/Translator'
1513
import { useTranslation } from 'react-i18next'
@@ -35,21 +33,9 @@ export const MessageViewBase = (props: MessageViewProps): JSX.Element => {
3533
const clipHeight = props.clipHeight ?? 450
3634
const [expanded, setExpanded] = useState(props.forceExpanded ?? false)
3735

38-
const { client } = useClient()
3936
const { t } = useTranslation('', { keyPrefix: 'common' })
4037
const { translatedText, processing } = useTranslator()
4138

42-
const [characterOverride, setProfileOverride] = useState<Profile<any> | undefined>(undefined)
43-
44-
useEffect(() => {
45-
if (!(client && props.message.document.body.profileOverride?.profileID)) return
46-
client.api
47-
.getProfile(props.message.document.body.profileOverride?.profileID, props.message.author)
48-
.then((profile) => {
49-
setProfileOverride(profile ?? undefined)
50-
})
51-
}, [client, props.message])
52-
5339
const reroutedsame = useMemo(() => {
5440
if (!props.rerouted) return false
5541
const A =
@@ -76,7 +62,6 @@ export const MessageViewBase = (props: MessageViewProps): JSX.Element => {
7662
apId={apId}
7763
>
7864
<MessageHeader
79-
usernameOverride={characterOverride?.parsedDoc.body.username}
8065
message={props.message}
8166
additionalMenuItems={props.additionalMenuItems}
8267
timeLink={props.message.document.meta?.apObjectRef} // Link to external message

app/src/components/Message/RerouteMessageFrame.tsx

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { Box, IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Tooltip, Typography } from '@mui/material'
22

33
import { type Message, type RerouteMessageSchema } from '@concrnt/worldlib'
4-
import { Profile } from '@concrnt/client'
54
import RepeatIcon from '@mui/icons-material/Repeat'
65
import { CCAvatar } from '../ui/CCAvatar'
76
import { Link as RouterLink } from 'react-router-dom'
87
import { TimeDiff } from '../ui/TimeDiff'
98
import { MessageContainer } from './MessageContainer'
109
import MoreHorizIcon from '@mui/icons-material/MoreHoriz'
11-
import { useEffect, useState } from 'react'
10+
import { useState } from 'react'
1211
import ManageSearchIcon from '@mui/icons-material/ManageSearch'
1312
import DeleteForeverIcon from '@mui/icons-material/DeleteForever'
1413
import { useClient } from '../../context/ClientContext'
@@ -32,27 +31,9 @@ export const RerouteMessageFrame = (props: RerouteMessageFrameProp): JSX.Element
3231
const { client } = useClient()
3332
const inspector = useInspector()
3433
const [menuAnchor, setMenuAnchor] = useState<null | HTMLElement>(null)
35-
const [character, setProfile] = useState<Profile<any> | null>(null)
3634
const confirm = useConfirm()
3735

38-
const profileOverride = props.message.document.body.profileOverride
39-
40-
const avatarURL =
41-
character?.parsedDoc.body.avatar ?? profileOverride?.avatar ?? props.message.authorUser?.profile?.avatar
42-
const username =
43-
character?.parsedDoc.body.username ??
44-
profileOverride?.username ??
45-
props.message.authorUser?.profile?.username ??
46-
'Anonymous'
47-
const link = profileOverride?.link ?? '/' + props.message.author
48-
49-
useEffect(() => {
50-
if (profileOverride?.profileID) {
51-
client.api.getProfile(profileOverride.profileID, props.message.author).then((character) => {
52-
setProfile(character ?? null)
53-
})
54-
}
55-
}, [profileOverride?.profileID])
36+
const link = props.message.document.body.profileOverride?.link ?? '/' + props.message.author
5637

5738
return (
5839
<>
@@ -73,7 +54,7 @@ export const RerouteMessageFrame = (props: RerouteMessageFrameProp): JSX.Element
7354
to={link}
7455
>
7556
<CCAvatar
76-
avatarURL={avatarURL}
57+
avatarURL={props.message.authorProfile.avatar}
7758
identiconSource={props.message.author}
7859
sx={{
7960
width: { xs: '12px', sm: '18px' },
@@ -100,9 +81,9 @@ export const RerouteMessageFrame = (props: RerouteMessageFrameProp): JSX.Element
10081
}}
10182
>
10283
<CCLink to={link} underline="hover" color="inherit">
103-
{username}
84+
{props.message.authorProfile.username ?? 'anonymous'}
10485
</CCLink>
105-
{profileOverride?.avatar && <FaTheaterMasks />} rerouted{' '}
86+
{props.message.authorProfile.original && <FaTheaterMasks />} rerouted{' '}
10687
{props.message.document.body.body && 'with comment:'}
10788
</Box>
10889
<Box display="flex" gap={0.5}>

0 commit comments

Comments
 (0)