diff --git a/src/common/pretty.js b/src/common/pretty.js
index 187a30d..09848b1 100644
--- a/src/common/pretty.js
+++ b/src/common/pretty.js
@@ -132,3 +132,11 @@ export function buildReactionFromUrl(reaction) {
return reaction.from_info?.service_external_url;
}
+
+export function truncateString(str, countDots = null) {
+ if (!str || str.length <= 1) {
+ return str;
+ }
+
+ return str[0] + '.'.repeat(countDots || str.length - 1);
+}
diff --git a/src/entries/contentScript/App.jsx b/src/entries/contentScript/App.jsx
index cfce8cb..d3e6cf5 100644
--- a/src/entries/contentScript/App.jsx
+++ b/src/entries/contentScript/App.jsx
@@ -172,9 +172,7 @@ function App() {
- {state !== STATE_LIVE && (
-
- )}
+
{state !== STATE_LIVE && (
diff --git a/src/entries/contentScript/components/ReactionsHistoryNotice.jsx b/src/entries/contentScript/components/ReactionsHistoryNotice.jsx
index df5c194..445ca9b 100644
--- a/src/entries/contentScript/components/ReactionsHistoryNotice.jsx
+++ b/src/entries/contentScript/components/ReactionsHistoryNotice.jsx
@@ -2,6 +2,7 @@
import React, { useMemo, Fragment } from 'react';
import moment from 'moment';
import { useTranslation } from 'react-i18next';
+import PropTypes from 'prop-types';
import Card from '~/entries/contentScript/components/Card';
import { useReactions } from '~/common/bridge';
import { reactionShape } from '~/shapes';
@@ -11,10 +12,14 @@ import useAuth from '~/hooks/useAuth';
import { hasSubscriptionFeature } from '~/entries/contentScript/hooks/useSubscription';
import { subscriptionIds, subscriptionFeatures } from '~/enums';
import PremiumCtaLabel from '~/entries/contentScript/components/PremiumCtaLabel';
-import { buildReactionFromUrl } from '~/common/pretty';
+import { buildReactionFromUrl, truncateString } from '~/common/pretty';
import imageOnError from '~/common/imageOnError';
+import TruncatedString from '~/entries/contentScript/components/TruncatedString';
-function ReactionPreview({ reaction }) {
+function ReactionPreview({
+ reaction,
+ truncateNames = false,
+}) {
const { t } = useTranslation();
const showAvatar = useMemo(() => reaction.from_info?.avatar_url, [reaction]);
@@ -56,7 +61,9 @@ function ReactionPreview({ reaction }) {
rel="noreferrer"
className="font-bold text-primary-gradient-hc-from dark:text-primary-gradient-from"
>
- {reaction.from_info?.display_name}
+ {truncateNames
+ ?
+ : reaction.from_info?.display_name}
{' '}
@@ -106,9 +113,12 @@ function ReactionPreview({ reaction }) {
ReactionPreview.propTypes = {
reaction: reactionShape.isRequired,
+ truncateNames: PropTypes.bool,
};
-function ReactionsHistoryNotice() {
+function ReactionsHistoryNotice({
+ truncateNames = false,
+}) {
const { t } = useTranslation();
const currentUrl = useAppStore((state) => state.currentUrl);
const compact = useAppStore((state) => state.isCompact);
@@ -196,7 +206,10 @@ function ReactionsHistoryNotice() {
{videoReactions.map((reaction) => (
-
+
))}
@@ -212,7 +225,10 @@ function ReactionsHistoryNotice() {
{liveReactions.map((reaction) => (
-
+
))}
@@ -224,7 +240,9 @@ function ReactionsHistoryNotice() {
);
}
-ReactionsHistoryNotice.propTypes = {};
+ReactionsHistoryNotice.propTypes = {
+ truncateNames: PropTypes.bool,
+};
ReactionsHistoryNotice.defaultProps = {};
diff --git a/src/entries/contentScript/components/TruncatedString.jsx b/src/entries/contentScript/components/TruncatedString.jsx
new file mode 100644
index 0000000..45c2db7
--- /dev/null
+++ b/src/entries/contentScript/components/TruncatedString.jsx
@@ -0,0 +1,20 @@
+import { useMemo } from 'react';
+import PropTypes from 'prop-types';
+import { truncateString } from '~/common/pretty';
+
+function TruncatedString({ value }) {
+ const truncated = useMemo(() => truncateString(value, 100), [value]);
+
+ return (
+
+ {value}
+ {truncated}
+
+ );
+}
+
+TruncatedString.propTypes = {
+ value: PropTypes.string,
+};
+
+export default TruncatedString;