From 8a301f8d68fc8a053465a6574861ae5414229d79 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Mon, 26 Aug 2024 13:54:11 +0900 Subject: [PATCH] wip --- .../src/components/EmNoteDetailed.vue | 5 ++--- .../src/to-be-shared/collapsed.ts | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 packages/frontend-embed/src/to-be-shared/collapsed.ts diff --git a/packages/frontend-embed/src/components/EmNoteDetailed.vue b/packages/frontend-embed/src/components/EmNoteDetailed.vue index 6021655cf6..5c7a7b6ee5 100644 --- a/packages/frontend-embed/src/components/EmNoteDetailed.vue +++ b/packages/frontend-embed/src/components/EmNoteDetailed.vue @@ -140,9 +140,8 @@ import { userPage } from '@/utils.js'; import { notePage } from '@/utils.js'; import number from '@/filters/number.js'; import { i18n } from '@/i18n.js'; -import { deepClone } from '@/scripts/clone.js'; import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js'; -import { shouldCollapsed } from '@/scripts/collapsed.js'; +import { shouldCollapsed } from '@/to-be-shared/collapsed.js'; import { instance } from '@/instance.js'; import { url } from '@/config.js'; @@ -152,7 +151,7 @@ const props = defineProps<{ const inChannel = inject('inChannel', null); -const note = ref(deepClone(props.note)); +const note = ref(props.note); const isRenote = ( note.value.renote != null && diff --git a/packages/frontend-embed/src/to-be-shared/collapsed.ts b/packages/frontend-embed/src/to-be-shared/collapsed.ts new file mode 100644 index 0000000000..4ec88a3c65 --- /dev/null +++ b/packages/frontend-embed/src/to-be-shared/collapsed.ts @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import * as Misskey from 'misskey-js'; + +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')) || + (note.text.includes('$[x4')) || + (note.text.includes('$[scale')) || + (note.text.split('\n').length > 9) || + (note.text.length > 500) || + (urls.length >= 4) + ) || note.files.length >= 5 + ); + + return collapsed; +}