enhance: 自動でたたまれる機能が返信先や引用RNにも適用されるように (#10989)
* 返信、引用RNでMFMがあったら自動で隠すように * Update CHANGELOG.md * Update MkSubNoteContent.vue * refactor: avoid `Boolean` * docs: update CHANGELOG.md --------- Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
parent
b3358f0a8b
commit
a8cd8ed99e
4 changed files with 25 additions and 16 deletions
19
packages/frontend/src/scripts/collapsed.ts
Normal file
19
packages/frontend/src/scripts/collapsed.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import * as mfm from 'mfm-js';
|
||||
import * as misskey from 'misskey-js';
|
||||
import { extractUrlFromMfm } from './extract-url-from-mfm';
|
||||
|
||||
export function shouldCollapsed(note: misskey.entities.Note): boolean {
|
||||
const urls = note.text ? extractUrlFromMfm(mfm.parse(note.text)) : null;
|
||||
const collapsed = note.cw == null && note.text != null && (
|
||||
(note.text.includes('$[x2')) ||
|
||||
(note.text.includes('$[x3')) ||
|
||||
(note.text.includes('$[x4')) ||
|
||||
(note.text.includes('$[scale')) ||
|
||||
(note.text.split('\n').length > 9) ||
|
||||
(note.text.length > 500) ||
|
||||
(note.files.length >= 5) ||
|
||||
(!!urls && urls.length >= 4)
|
||||
);
|
||||
|
||||
return collapsed;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue