From d6fe89792350d699ff1ad5dcf639fef19dffa91d Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2023 10:23:20 +0900 Subject: perf(frontend): ノート表示時のMFMパース処理を減らす MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/scripts/collapsed.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'packages/frontend/src/scripts/collapsed.ts') diff --git a/packages/frontend/src/scripts/collapsed.ts b/packages/frontend/src/scripts/collapsed.ts index c3c767bcfa..57e6ecf5b5 100644 --- a/packages/frontend/src/scripts/collapsed.ts +++ b/packages/frontend/src/scripts/collapsed.ts @@ -3,12 +3,9 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import * as mfm from 'mfm-js'; import * as Misskey from 'misskey-js'; -import { extractUrlFromMfm } from './extract-url-from-mfm.js'; -export function shouldCollapsed(note: Misskey.entities.Note): boolean { - const urls = note.text ? extractUrlFromMfm(mfm.parse(note.text)) : null; +export function shouldCollapsed(note: Misskey.entities.Note, urls: string[]): boolean { const collapsed = note.cw == null && note.text != null && ( (note.text.includes('$[x2')) || (note.text.includes('$[x3')) || @@ -17,7 +14,7 @@ export function shouldCollapsed(note: Misskey.entities.Note): boolean { (note.text.split('\n').length > 9) || (note.text.length > 500) || (note.files.length >= 5) || - (!!urls && urls.length >= 4) + (urls.length >= 4) ); return collapsed; -- cgit v1.2.3-freya