From d008394eb76b7b615258667dbba3d2e12acdf0f3 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 7 Feb 2025 15:54:52 +0900 Subject: enhance(frontend): PostFormのannoying判定でCWを考慮するように (#15405) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(frontend): PostFormのannoying判定でCWを考慮するように * Update Changelog * Update CHANGELOG.md --- packages/frontend/src/components/MkPostForm.vue | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'packages/frontend/src/components/MkPostForm.vue') diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 4f2792ed40..49ed4197de 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -721,6 +721,14 @@ function deleteDraft() { miLocalStorage.setItem('drafts', JSON.stringify(draftData)); } +function isAnnoying(text: string): boolean { + return text.includes('$[x2') || + text.includes('$[x3') || + text.includes('$[x4') || + text.includes('$[scale') || + text.includes('$[position'); +} + async function post(ev?: MouseEvent) { if (useCw.value && (cw.value == null || cw.value.trim() === '')) { os.alert({ @@ -745,14 +753,10 @@ async function post(ev?: MouseEvent) { if (props.mock) return; - const annoying = - text.value.includes('$[x2') || - text.value.includes('$[x3') || - text.value.includes('$[x4') || - text.value.includes('$[scale') || - text.value.includes('$[position'); - - if (annoying && visibility.value === 'public') { + if (visibility.value === 'public' && ( + (useCw.value && cw.value != null && cw.value.trim() !== '' && isAnnoying(cw.value)) || // CWが迷惑になる場合 + ((!useCw.value || cw.value == null || cw.value.trim() === '') && text.value != null && text.value.trim() !== '' && isAnnoying(text.value)) // CWが無い かつ 本文が迷惑になる場合 + )) { const { canceled, result } = await os.actions({ type: 'warning', text: i18n.ts.thisPostMayBeAnnoying, -- cgit v1.2.3-freya