1
+ import type { APIRole , APIUser , Snowflake } from "discord-api-types/v10" ;
1
2
import * as React from "react" ;
2
3
import type { ComponentProps } from "react" ;
3
4
import { useMemo } from "react" ;
5
+ import { useTranslation } from "react-i18next" ;
4
6
import ChatTag from "../ChatTag" ;
5
- import RoleIcon from "./RoleIcon" ;
6
- import getAvatar from "../utils/getAvatar" ;
7
- import * as Styles from "./style/author" ;
8
- import type { APIRole , APIUser , Snowflake } from "discord-api-types/v10" ;
9
7
import { useConfig } from "../core/ConfigContext" ;
8
+ import getAvatar from "../utils/getAvatar" ;
10
9
import getDisplayName from "../utils/getDisplayName" ;
11
- import { useTranslation } from "react-i18next" ;
10
+ import RoleIcon from "./RoleIcon" ;
11
+ import * as Styles from "./style/author" ;
12
12
13
13
interface AutomodAuthorProps {
14
14
isAvatarAnimated ?: boolean ;
@@ -96,14 +96,19 @@ function MessageAuthor({
96
96
return color > 0 ? `#${ color . toString ( 16 ) . padStart ( 6 , "0" ) } ` : undefined ;
97
97
} , [ isGuildMember , resolveRole , member ] ) ;
98
98
99
+ const clickable = userOnClick !== undefined ;
100
+
99
101
if ( onlyShowUsername ) {
100
102
return (
101
103
< Styles . MessageAuthor
102
- clickable = { userOnClick !== undefined }
104
+ clickable = { clickable }
103
105
{ ...props }
104
106
onClick = { ( e ) => userOnClick ?.( author , e . currentTarget ) }
105
107
>
106
- < Styles . Username style = { { color : dominantRoleColor } } >
108
+ < Styles . Username
109
+ clickable = { clickable }
110
+ style = { { color : dominantRoleColor } }
111
+ >
107
112
{ displayName }
108
113
</ Styles . Username >
109
114
</ Styles . MessageAuthor >
@@ -112,7 +117,7 @@ function MessageAuthor({
112
117
113
118
return (
114
119
< Styles . MessageAuthor
115
- clickable = { userOnClick !== undefined }
120
+ clickable = { clickable }
116
121
{ ...props }
117
122
onClick = { ( e ) => userOnClick ?.( author , e . currentTarget ) }
118
123
>
@@ -150,9 +155,13 @@ function MessageAuthor({
150
155
</ Styles . AnimatedAvatar >
151
156
) }
152
157
</ Styles . AnimatedAvatarTrigger >
153
- < Styles . Username style = { { color : dominantRoleColor } } >
158
+ < Styles . Username
159
+ clickable = { clickable }
160
+ style = { { color : dominantRoleColor } }
161
+ >
154
162
{ displayName }
155
163
</ Styles . Username >
164
+
156
165
{ dominantRoleIconRole !== null && (
157
166
< RoleIcon role = { dominantRoleIconRole } />
158
167
) }
0 commit comments