From b0fe6ea04897fcadff59d081a0c087c2cacea26d Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 28 Apr 2024 21:05:16 +0900 Subject: [PATCH] =?UTF-8?q?ast=E3=81=8C=E6=8F=90=E4=BE=9B=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AF=E3=83=91=E3=83=BC=E3=82=B9=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/scripts/collapsed.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/scripts/collapsed.ts b/packages/frontend/src/scripts/collapsed.ts index bfb70867e8..ad83b648cf 100644 --- a/packages/frontend/src/scripts/collapsed.ts +++ b/packages/frontend/src/scripts/collapsed.ts @@ -10,10 +10,12 @@ import { safeParseFloat } from './safe-parse.js'; export function shouldCollapsed(note: Misskey.entities.Note, ast?: mfm.MfmNode[] | null, urls?: string[]): boolean { if (note.cw != null) return false; if (note.text == null) return false; - if (ast == null) return false; if (note.files && note.files.length >= 5) return true; if (urls && urls.length >= 4) return true; + // ASTが提供されていない場合はパースしちゃう + const _ast = ast ?? mfm.parse(note.text); + // しきい値(X方向の文字数は半角換算) const limitX = 55; const limitY = 13.5; @@ -197,7 +199,7 @@ export function shouldCollapsed(note: Misskey.entities.Note, ast?: mfm.MfmNode[] return vHeight; } - const virtualHeight = getHeight(ast); + const virtualHeight = getHeight(_ast); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition return forceCollapsed || virtualHeight > limitY;