fix feed glitch by memoizing NoteText
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Martti Malmi 2024-02-12 12:54:11 +02:00
parent 96947fad2e
commit 512307f42d
2 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import React, { useState } from "react"; import React, { memo, useState } from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
@ -9,7 +9,7 @@ import Text from "@/Components/Text/Text";
import useLogin from "@/Hooks/useLogin"; import useLogin from "@/Hooks/useLogin";
const TEXT_TRUNCATE_LENGTH = 400; const TEXT_TRUNCATE_LENGTH = 400;
export const NoteText = function InnerContent( export const NoteText = memo(function InnerContent(
props: NoteProps & { translated: NoteTranslation; showTranslation?: boolean }, props: NoteProps & { translated: NoteTranslation; showTranslation?: boolean },
) { ) {
const { data: ev, options, translated, showTranslation } = props; const { data: ev, options, translated, showTranslation } = props;
@ -94,4 +94,4 @@ export const NoteText = function InnerContent(
} }
} }
return innerContent; return innerContent;
}; });

View File

@ -43,6 +43,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
); );
const feed = useTimelineFeed(subject, { method: "TIME_RANGE" } as TimelineFeedOptions); const feed = useTimelineFeed(subject, { method: "TIME_RANGE" } as TimelineFeedOptions);
// TODO allow reposts:
const postsOnly = useCallback( const postsOnly = useCallback(
(a: NostrEvent) => (props.postsOnly ? !a.tags.some(b => b[0] === "e" || b[0] === "a") : true), (a: NostrEvent) => (props.postsOnly ? !a.tags.some(b => b[0] === "e" || b[0] === "a") : true),
[props.postsOnly], [props.postsOnly],