From f635236f0075a00af2903a4cd327caf2fbb7699d Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 21 Jul 2023 13:48:27 +0000 Subject: [PATCH] feat: add "re:" at the beginning of CW reply comment (close #52) --- README.md | 2 ++ locales/en-US.yml | 1 + locales/ja-JP.yml | 1 + packages/client/src/components/MkPostForm.vue | 15 ++++++++++++++- packages/client/src/pages/settings/general.vue | 7 +++++++ packages/client/src/store.ts | 4 ++++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f633f9c6..64f576f1 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ ## 細かい変更点 +- 閲覧注意の投稿への返信で注釈の先頭に "re:" をつける設定を追加 + - 返信で閲覧注意は維持したいけどそのままの注釈を用いるのには違和感を覚えることがよくあるため - NSFW メディアを隠す設定をブラウザごとの設定からブラウザごとかつアカウントごとの設定に変更 - 「このアカウントでは NSFW の画像を常に表示したい」みたいな需要が私にあったため - インスタンスティッカーをデフォルトで常に表示する diff --git a/locales/en-US.yml b/locales/en-US.yml index 676f94df..cf55d426 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1132,6 +1132,7 @@ hideFollowButtons: "Hide follow buttons in notifications and user pages" forMobile: "Mobile" replaceChatButtonWithAccountButton: "Replace chat button at the bottom with account switch button" replaceWidgetsButtonWithReloadButton: "Replace widgets button at the bottom with reload button" +addRe: "Add \"re:\" at the beginning of comment in reply to CW'd post" _sensitiveMediaDetection: description: "Reduces the effort of server moderation through automatically recognizing diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index e9a49e1e..b89f741f 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -992,6 +992,7 @@ hideFollowButtons: "新規フォロワーの通知とユーザーページの .. forMobile: "モバイル向け" replaceChatButtonWithAccountButton: "画面下部のチャットのボタンをアカウント切り替えボタンに変更する" replaceWidgetsButtonWithReloadButton: "画面下部のウィジェットのボタンを再読み込みボタンに変更する" +addRe: "閲覧注意の投稿への返信で、注釈の先頭に\"re:\"を追加する" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てられます。サーバーの負荷が少し増えます。" diff --git a/packages/client/src/components/MkPostForm.vue b/packages/client/src/components/MkPostForm.vue index 79c31bcc..df348ba3 100644 --- a/packages/client/src/components/MkPostForm.vue +++ b/packages/client/src/components/MkPostForm.vue @@ -518,10 +518,23 @@ if (props.specified) { pushVisibleUser(props.specified); } +const addRe = (s: string) => { + if ( + !defaultStore.state.addRe || + s.trim() === "" || + s.slice(0, 3).toLowerCase() === "re:" + ) + return s; + return `re: ${s}`; +}; + // keep cw when reply if (defaultStore.state.keepCw && props.reply && props.reply.cw) { useCw = true; - cw = props.reply.cw; + cw = + props.reply.user.username === $i.username + ? props.reply.cw + : addRe(props.reply.cw); } function watchForDraft() { diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index e3a25ddf..9b832905 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -77,6 +77,12 @@ {{ i18n.ts.reflectMayTakeTime }} + {{ i18n.ts.addRe + }}{{ + i18n.ts.originalFeature + }} @@ -405,6 +411,7 @@ const replaceChatButtonWithAccountButton = computed( const replaceWidgetsButtonWithReloadButton = computed( defaultStore.makeGetterSetter("replaceWidgetsButtonWithReloadButton"), ); +const addRe = computed(defaultStore.makeGetterSetter("addRe")); watch(swipeOnDesktop, () => { defaultStore.set("swipeOnMobile", true); diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index 6aeaca64..af45f7b5 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -358,6 +358,10 @@ export const defaultStore = markRaw( where: "device", default: true, }, + addRe: { + where: "account", + default: true, + }, }), );