Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions app/src/components/Association/FavoriteAssociation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
type ReplyMessageSchema,
type MarkdownMessageSchema,
type User,
MediaMessageSchema
MediaMessageSchema,
UserProfile
} from '@concrnt/worldlib'
import { ContentWithCCAvatar } from '../ContentWithCCAvatar'
import { Box, IconButton, Link, ListItemIcon, ListItemText, Menu, MenuItem, Typography } from '@mui/material'
Expand Down Expand Up @@ -37,33 +38,23 @@ export const FavoriteAssociation = (props: FavoriteAssociationProps): JSX.Elemen
> | null>(null)
const isMeToOther = props.association?.authorUser?.ccid !== props.perspective

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

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

const masked =
(isMeToOther ? props.association.document.body.profileOverride : target?.document.body.profileOverride) !==
undefined
(isMeToOther ? props.association.authorProfile.original : target?.authorProfile.original) !== undefined

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

return (
<ContentWithCCAvatar
author={actionUser}
linkTo={targetLink}
profileOverride={
isMeToOther ? props.association.document.body.profileOverride : target?.document.body.profileOverride
}
>
<ContentWithCCAvatar author={actionUser} linkTo={targetLink} profile={actionUserProfile}>
<Box display="flex" justifyContent="space-between" alignItems="center">
<Box display="flex" overflow="hidden">
<Box display="flex" alignItems="center" flexShrink={0} gap={0.5}>
Expand Down
15 changes: 6 additions & 9 deletions app/src/components/Association/MentionAssociation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
type Message,
type ReplyMessageSchema,
type MarkdownMessageSchema,
type User
type User,
UserProfile
} from '@concrnt/worldlib'
import { ContentWithCCAvatar } from '../ContentWithCCAvatar'
import { Box, Typography } from '@mui/material'
Expand All @@ -22,23 +23,19 @@ export const MentionAssociation = (props: MentionAssociationProps): ReactElement
const [target, setTarget] = useState<Message<MarkdownMessageSchema | ReplyMessageSchema> | null>(null)
const isMeToOther = props.association?.authorUser?.ccid !== props.perspective

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

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

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

return (
<ContentWithCCAvatar
author={actionUser}
linkTo={targetLink}
profileOverride={!isMeToOther ? target?.document.body.profileOverride : undefined}
>
<ContentWithCCAvatar author={actionUser} linkTo={targetLink} profile={actionUserProfile}>
<Box display="flex" justifyContent="space-between">
<Typography>
{isMeToOther ? (
Expand Down
24 changes: 8 additions & 16 deletions app/src/components/Association/ReactionAssociation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
type ReplyMessageSchema,
type MarkdownMessageSchema,
type User,
MediaMessageSchema
MediaMessageSchema,
UserProfile
} from '@concrnt/worldlib'
import { ContentWithCCAvatar } from '../ContentWithCCAvatar'
import { Box, IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Typography } from '@mui/material'
Expand Down Expand Up @@ -36,33 +37,24 @@ export const ReactionAssociation = (props: ReactionAssociationProps): JSX.Elemen
> | null>(null)
const isMeToOther = props.association?.authorUser?.ccid !== props.perspective

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

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

const [menuAnchor, setMenuAnchor] = useState<null | HTMLElement>(null)

const masked =
(isMeToOther ? props.association.document.body.profileOverride : target?.document.body.profileOverride) !==
undefined
(isMeToOther ? props.association.authorProfile.original : target?.authorProfile.original) !== undefined

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

return (
<ContentWithCCAvatar
author={actionUser}
linkTo={targetLink}
profileOverride={
isMeToOther ? props.association.document.body.profileOverride : target?.document.body.profileOverride
}
>
<ContentWithCCAvatar author={actionUser} linkTo={targetLink} profile={actionUserProfile}>
<Box display="flex" justifyContent="space-between" alignItems="center">
<Box display="flex" overflow="hidden">
<Box display="flex" alignItems="center" flexShrink={0} gap={0.5}>
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/Association/ReadAccessAssociation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ export const ReadAccessAssociation = (props: ReadAccessAssociationProps): ReactE
}, [props.association])

return (
<ContentWithCCAvatar author={props.association.authorUser}>
<ContentWithCCAvatar author={props.association.authorUser} profile={props.association.authorProfile}>
<Box display="flex" justifyContent="space-between">
<Typography>
<Trans
i18nKey="pages.associations.readAccessRequest"
components={{
username: (
<CCLink to={`/${props.association.author}`}>
{props.association.authorUser?.profile?.username}
{props.association.authorProfile.username}
</CCLink>
),
timeline: (
Expand Down
40 changes: 15 additions & 25 deletions app/src/components/ContentWithCCAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {
User,
type MarkdownMessageSchema,
type Message,
type ReplyMessageSchema,
type ProfileSchema,
type User,
type ProfileOverride
type UserProfile
} from '@concrnt/worldlib'
import { Box, IconButton, ListItem, type SxProps } from '@mui/material'
import { Link as routerLink, useNavigate, useLocation } from 'react-router-dom'
Expand All @@ -16,9 +15,7 @@ export interface ContentWithCCAvatarProps {
message?: Message<MarkdownMessageSchema | ReplyMessageSchema>
linkTo?: string
author?: User
profileOverride?: ProfileOverride
characterOverride?: ProfileSchema
avatarOverride?: string
profile: UserProfile
children?: JSX.Element | Array<JSX.Element | undefined>
sx?: SxProps
apId?: string
Expand All @@ -37,16 +34,14 @@ export const ContentWithCCAvatar = (props: ContentWithCCAvatarProps): JSX.Elemen
return (
<>
<Box itemProp="author" itemScope itemType="https://schema.org/Person">
{props.author && (
<>
<meta itemProp="identifier" content={props.profile.ccid} />
<meta itemProp="url" content={'https://concrnt.world/' + props.profile.ccid} />
</>
{props.profile.alias && <meta itemProp="alternateName" content={props.profile.alias} />}
{props.profile.username && (
<>
<meta itemProp="identifier" content={props.author.ccid} />
<meta itemProp="url" content={'https://concrnt.world/' + props.author.ccid} />
</>
)}
{props.author?.alias && <meta itemProp="alternateName" content={props.author.alias} />}
{props.author?.profile?.username && (
<>
<meta itemProp="name" content={props.author.profile.username} />
<meta itemProp="name" content={props.profile.username} />
</>
)}
</Box>
Expand All @@ -73,11 +68,7 @@ export const ContentWithCCAvatar = (props: ContentWithCCAvatarProps): JSX.Elemen
e.stopPropagation() // prevent to navigate other page
}}
>
<ProfileTooltip
user={props.author}
subProfileID={props.profileOverride?.profileID}
profileOverride={props.profileOverride}
>
<ProfileTooltip user={props.author} profile={props.profile}>
<IconButton
sx={{
width: { xs: '38px', sm: '48px' },
Expand All @@ -88,15 +79,14 @@ export const ContentWithCCAvatar = (props: ContentWithCCAvatarProps): JSX.Elemen
to={
apLink ??
'/' +
(props.author?.ccid ?? '') +
(props.profileOverride?.profileID ? '#' + props.profileOverride.profileID : '')
(props.profile.ccid ?? '') +
(props.profile.profileOverrideID ? '#' + props.profile.profileOverrideID : '')
}
onPointerDown={() => profile.forceClose()} // prevent to stick showing when clicking
>
<CCAvatar
avatarURL={props.author?.profile?.avatar}
avatarOverride={props.avatarOverride || props.profileOverride?.avatar}
identiconSource={props.author?.ccid ?? ''}
avatarURL={props.profile.avatar}
identiconSource={props.profile.ccid}
sx={{
width: { xs: '38px', sm: '48px' },
height: { xs: '38px', sm: '48px' }
Expand Down
16 changes: 7 additions & 9 deletions app/src/components/Message/MessageActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ export const MessageActions = (props: MessageActionsProps): JSX.Element => {
textDecoration: 'none'
}}
component={RouterLink}
to={fav.document.body.profileOverride?.link ?? '/' + fav.author}
target={fav.document.body.profileOverride?.link ? '_blank' : undefined}
rel={fav.document.body.profileOverride?.link ? 'noopener noreferrer' : undefined}
to={
fav.document.meta?.apActorId
? `/ap${fav.document.meta.apActorId}`
: `/${fav.author}`
}
onClick={(e) => {
e.stopPropagation()
}}
Expand All @@ -148,9 +150,7 @@ export const MessageActions = (props: MessageActionsProps): JSX.Element => {
height: '20px',
width: '20px'
}}
avatarURL={
fav.document.body.profileOverride?.avatar ?? fav.authorUser?.profile?.avatar
}
avatarURL={fav.authorProfile.avatar}
identiconSource={fav.author}
/>
<Typography
Expand All @@ -159,9 +159,7 @@ export const MessageActions = (props: MessageActionsProps): JSX.Element => {
color: '#fff'
}}
>
{fav.document.body.profileOverride?.username ||
fav.authorUser?.profile?.username ||
'anonymous'}
{fav.authorProfile.username ?? 'anonymous'}
</Typography>
</Box>
))}
Expand Down
12 changes: 6 additions & 6 deletions app/src/components/Message/MessageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { useTranslation } from 'react-i18next'

export interface MessageHeaderProps {
message: Message<MarkdownMessageSchema | ReplyMessageSchema>
usernameOverride?: string
additionalMenuItems?: JSX.Element | JSX.Element[]
timeLink?: string
}
Expand Down Expand Up @@ -52,7 +51,11 @@ export const MessageHeader = (props: MessageHeaderProps): JSX.Element => {
<CCLink
underline="hover"
color="inherit"
to={props.message.document.body.profileOverride?.link ?? `/${props.message.author}`}
to={
props.message.document.meta?.apActorId
? `/ap/${props.message.document.meta.apActorId}`
: `/${props.message.author}`
}
sx={{
flexShrink: 0
}}
Expand All @@ -64,10 +67,7 @@ export const MessageHeader = (props: MessageHeaderProps): JSX.Element => {
fontSize: { xs: '0.9rem', sm: '0.95rem' }
}}
>
{props.usernameOverride ||
props.message.document.body.profileOverride?.username ||
props.message.authorUser?.profile?.username ||
'anonymous'}
{props.message.authorProfile.username || 'anonymous'}
</Typography>
</CCLink>
{props.message.document.body.profileOverride &&
Expand Down
25 changes: 9 additions & 16 deletions app/src/components/Message/MessageReactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ export const MessageReactions = (props: MessageReactionsProps): JSX.Element => {
to={'/' + reaction.reaction.author}
>
<CCAvatar
avatarURL={reaction.reaction.authorUser?.profile?.avatar}
identiconSource={reaction.reaction.author}
avatarURL={reaction.reaction.authorProfile.avatar}
identiconSource={reaction.reaction.authorProfile.ccid}
sx={{
width: { xs: '12px', sm: '18px' },
height: { xs: '12px', sm: '18px' }
Expand All @@ -167,7 +167,7 @@ export const MessageReactions = (props: MessageReactionsProps): JSX.Element => {
color: '#fff'
}}
>
{reaction.reaction.authorUser?.profile?.username || 'anonymous'}
{reaction.reaction.authorProfile.username || 'anonymous'}
</Typography>
</Box>
</Box>
Expand Down Expand Up @@ -224,22 +224,17 @@ export const MessageReactions = (props: MessageReactionsProps): JSX.Element => {
textDecoration: 'none'
}}
component={routerLink}
to={reaction.document.body.profileOverride?.link ?? '/' + reaction.author}
target={reaction.document.body.profileOverride?.link ? '_blank' : undefined}
rel={
reaction.document.body.profileOverride?.link
? 'noopener noreferrer'
: undefined
to={
reaction.document.meta?.apActorId
? `/ap/${reaction.document.meta.apActorId}`
: `/${reaction.author}`
}
onClick={(e) => {
e.stopPropagation()
}}
>
<CCAvatar
avatarURL={
reaction.document.body.profileOverride?.avatar ??
reaction.authorUser?.profile?.avatar
}
avatarURL={reaction.authorProfile.avatar}
identiconSource={reaction.author}
sx={{
width: { xs: '12px', sm: '18px' },
Expand All @@ -252,9 +247,7 @@ export const MessageReactions = (props: MessageReactionsProps): JSX.Element => {
color: '#fff'
}}
>
{reaction.document.body.profileOverride?.username ||
reaction.authorUser?.profile?.username ||
'anonymous'}
{reaction.authorProfile.username || 'anonymous'}
</Typography>
</Box>
))}
Expand Down
Loading