Skip to content

Commit

Permalink
enhance(frontend): PostFormのannoying判定でCWを考慮するように (misskey-dev#15405)
Browse files Browse the repository at this point in the history
* enhance(frontend): PostFormのannoying判定でCWを考慮するように

* Update Changelog

* Update CHANGELOG.md
  • Loading branch information
kakkokari-gtyih authored and DA-TENSHI committed Feb 7, 2025
1 parent 67bfa22 commit 53768a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

### Note
- ページの「ソースを見る」機能は削除されました
### General
-

### Client
- Enhance: 投稿フォームの「迷惑になる可能性があります」のダイアログを表示する条件においてCWを考慮するように

### Server
-


## 2025.2.0

### General
- Fix: Docker のビルドに失敗する問題を修正
Expand Down
20 changes: 12 additions & 8 deletions packages/frontend/src/components/MkPostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
Expand Down

0 comments on commit 53768a5

Please sign in to comment.