diff --git a/src/components/account-block.jsx b/src/components/account-block.jsx
index 9d104b4c..d197ff9d 100644
--- a/src/components/account-block.jsx
+++ b/src/components/account-block.jsx
@@ -4,7 +4,6 @@ import { Plural, Trans, useLingui } from '@lingui/react/macro';
// import { useNavigate } from 'react-router-dom';
import enhanceContent from '../utils/enhance-content';
-import getDomain from '../utils/get-domain';
import niceDateTime from '../utils/nice-date-time';
import shortenNumber from '../utils/shorten-number';
import states from '../utils/states';
@@ -12,6 +11,7 @@ import states from '../utils/states';
import Avatar from './avatar';
import EmojiText from './emoji-text';
import Icon from './icon';
+import RolesTags from './roles-tags';
function AccountBlock({
skeleton,
@@ -74,8 +74,6 @@ function AccountBlock({
acct2 = `@${accountInstance}`;
}
- const parsedAccountInstance = getDomain(url);
-
const verifiedField = fields?.find((f) => !!f.verifiedAt && !!f.value);
const excludedRelationship = {};
@@ -142,22 +140,7 @@ function AccountBlock({
>
)}
- {roles?.map((role) => (
- <>
- {' '}
-
- {role.name}
- {!!parsedAccountInstance && (
- <>
- {' '}
-
- {parsedAccountInstance}
-
- >
- )}
-
- >
- ))}
+
{showActivity && (
Posts: {shortenNumber(statusesCount)}
diff --git a/src/components/name-text.jsx b/src/components/name-text.jsx
index e94cca3e..c34eddc3 100644
--- a/src/components/name-text.jsx
+++ b/src/components/name-text.jsx
@@ -10,6 +10,7 @@ import states from '../utils/states';
import Avatar from './avatar';
import EmojiText from './emoji-text';
+import RolesTags from './roles-tags';
const nameCollator = mem((locale) => {
const options = {
@@ -118,22 +119,12 @@ function NameText({
<>
{' '}
@{username}
- {roles?.map((role) => (
- <>
- {' '}
-
- {role.name}
- {!!accountInstance && (
- <>
- {' '}
-
- {accountInstance}
-
- >
- )}
-
- >
- ))}
+
>
)}
>
@@ -150,20 +141,7 @@ function NameText({
{acct1}
{!!acct2 && {acct2}}
- {roles?.map((role) => (
- <>
- {' '}
-
- {role.name}
- {!!accountInstance && (
- <>
- {' '}
- {accountInstance}
- >
- )}
-
- >
- ))}
+
>
)}
diff --git a/src/components/roles-tags.jsx b/src/components/roles-tags.jsx
new file mode 100644
index 00000000..ebd9758b
--- /dev/null
+++ b/src/components/roles-tags.jsx
@@ -0,0 +1,31 @@
+import getDomain from '../utils/get-domain';
+import { getCurrentAccountID } from '../utils/store-utils';
+
+function RolesTags({ roles, accountId, accountUrl, hideSelf = false }) {
+ if (!roles?.length) return null;
+
+ const isSelf = accountId && accountId === getCurrentAccountID();
+ if (!accountId && hideSelf) {
+ console.warn('accountId is required if hideSelf is true');
+ }
+ if (hideSelf && isSelf) return null;
+
+ const parsedAccountInstance = getDomain(accountUrl);
+
+ return roles?.map((role) => (
+ <>
+ {' '}
+
+ {role.name}
+ {!!parsedAccountInstance && (
+ <>
+ {' '}
+ {parsedAccountInstance}
+ >
+ )}
+
+ >
+ ));
+}
+
+export default RolesTags;
diff --git a/src/locales/en.po b/src/locales/en.po
index 47bac366..53e398ca 100644
--- a/src/locales/en.po
+++ b/src/locales/en.po
@@ -13,62 +13,62 @@ msgstr ""
"Language-Team: \n"
"Plural-Forms: \n"
-#: src/components/account-block.jsx:141
+#: src/components/account-block.jsx:139
msgid "Locked"
msgstr ""
#. placeholder {0}: shortenNumber(statusesCount)
-#: src/components/account-block.jsx:163
+#: src/components/account-block.jsx:146
msgid "Posts: {0}"
msgstr ""
#. placeholder {0}: niceDateTime(lastStatusAt, { hideTime: true, })
-#: src/components/account-block.jsx:168
+#: src/components/account-block.jsx:151
msgid "Last posted: {0}"
msgstr ""
-#: src/components/account-block.jsx:183
+#: src/components/account-block.jsx:166
#: src/components/account-info.jsx:670
msgid "Automated"
msgstr ""
-#: src/components/account-block.jsx:190
+#: src/components/account-block.jsx:173
#: src/components/account-info.jsx:675
#: src/components/status.jsx:529
msgid "Group"
msgstr ""
-#: src/components/account-block.jsx:200
+#: src/components/account-block.jsx:183
msgid "Mutual"
msgstr ""
-#: src/components/account-block.jsx:204
+#: src/components/account-block.jsx:187
#: src/components/related-actions.jsx:882
msgid "Requested"
msgstr ""
-#: src/components/account-block.jsx:208
+#: src/components/account-block.jsx:191
#: src/components/related-actions.jsx:873
msgid "Following"
msgstr ""
-#: src/components/account-block.jsx:212
+#: src/components/account-block.jsx:195
#: src/components/related-actions.jsx:182
msgid "Follows you"
msgstr ""
-#: src/components/account-block.jsx:220
+#: src/components/account-block.jsx:203
msgid "{followersCount, plural, one {# follower} other {# followers}}"
msgstr ""
-#: src/components/account-block.jsx:229
+#: src/components/account-block.jsx:212
#: src/components/account-info.jsx:718
msgid "Verified"
msgstr ""
#. placeholder {0}: niceDateTime(createdAt, { hideTime: true, })
#. placeholder {0}: niceDateTime(createdAt, { hideTime: true, })
-#: src/components/account-block.jsx:244
+#: src/components/account-block.jsx:227
#: src/components/account-info.jsx:857
msgid "Joined <0>{0}0>"
msgstr ""