Skip to content

Commit

Permalink
chore: Update translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieran committed Sep 29, 2023
1 parent 1d1e888 commit fc38049
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
9 changes: 8 additions & 1 deletion packages/app/src/Element/Feed/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ const Timeline = (props: TimelineProps) => {
</>
)}
{mainFeed.map(e => (
<Note key={e.id} searchedValue={props.subject.discriminator} data={e} related={relatedFeed(e.id)} ignoreModeration={props.ignoreModeration} depth={0} />
<Note
key={e.id}
searchedValue={props.subject.discriminator}
data={e}
related={relatedFeed(e.id)}
ignoreModeration={props.ignoreModeration}
depth={0}
/>
))}
{(props.loadMore === undefined || props.loadMore === true) && (
<div className="flex f-center">
Expand Down
6 changes: 1 addition & 5 deletions packages/app/src/Element/HighlightedText.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const HighlightedText = ({ content }: { content: string }) => {
return (
<strong className="highlighted-text">
{content}
</strong>
);
return <strong className="highlighted-text">{content}</strong>;
};

export default HighlightedText;
16 changes: 9 additions & 7 deletions packages/app/src/Element/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ export default function Text({
const images = elements.filter(a => a.type === "media" && a.mimeType?.startsWith("image")).map(a => a.content);

function renderContentWithHighlightedText(content: string, textToHighlight: string) {
const textToHighlightArray = textToHighlight.trim().toLowerCase().split(' ');
const re = new RegExp(`(${textToHighlightArray.join('|')})`, 'gi');
const textToHighlightArray = textToHighlight.trim().toLowerCase().split(" ");
const re = new RegExp(`(${textToHighlightArray.join("|")})`, "gi");
const splittedContent = content.split(re);

const fragments = splittedContent.map(c => {
if (textToHighlightArray.includes(c.toLowerCase())) {
return {
type: 'highlighted_text',
type: "highlighted_text",
content: c,
} as ParsedFragment;
}

return c;
})
});

return (
<>
Expand Down Expand Up @@ -128,9 +128,11 @@ export default function Text({
case "custom_emoji":
return <ProxyImg src={a.content} size={15} className="custom-emoji" />;
default:
return <div className="text-frag">
{highlighText ? renderContentWithHighlightedText(a.content, highlighText) : a.content}
</div>;
return (
<div className="text-frag">
{highlighText ? renderContentWithHighlightedText(a.content, highlighText) : a.content}
</div>
);
}
}
}
Expand Down

0 comments on commit fc38049

Please sign in to comment.