perf(frontend): ノート表示時のMFMパース処理を減らす

This commit is contained in:
syuilo 2023-11-01 10:23:20 +09:00
parent bf01c1ee64
commit d6fe897923
5 changed files with 12 additions and 12 deletions

View file

@ -38,6 +38,7 @@ type MfmProps = {
emojiUrls?: string[];
rootScale?: number;
nyaize: boolean | 'account';
parsedNodes?: mfm.MfmNode[] | null;
};
// eslint-disable-next-line import/no-default-export
@ -48,7 +49,7 @@ export default function(props: MfmProps) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (props.text == null || props.text === '') return;
const rootAst = (props.plain ? mfm.parseSimple : mfm.parse)(props.text);
const rootAst = props.parsedNodes ?? (props.plain ? mfm.parseSimple : mfm.parse)(props.text);
const validTime = (t: string | null | undefined) => {
if (t == null) return null;