From 61f4a03e6cd65af4a825f666acd31f4853c5bbad Mon Sep 17 00:00:00 2001
From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com>
Date: Sun, 28 Jul 2024 11:19:32 +0900
Subject: [PATCH] =?UTF-8?q?Fix(frontend):=20=E4=B8=8B=E6=9B=B8=E3=81=8D/?=
 =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=97=E3=81=A6=E7=B7=A8=E9=9B=86=E3=81=A7?=
 =?UTF-8?q?=E4=BF=9D=E6=8C=81=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E9=A0=85?=
 =?UTF-8?q?=E7=9B=AE=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F=E5=95=8F=E9=A1=8C?=
 =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=20(#14285)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* chore(frontend): reorder assignments

* fix(frontend): visibleUserIds is not kept when deleteAndEdit

* fix(frontend): quoteId is not kept on draft

* fix(frontend): reactionAcceptance is not kept for draft/deleteAndEdit

* docs(changelog): update changelog
---
 CHANGELOG.md                                  |  3 +++
 .../backend/src/models/json-schema/note.ts    |  1 +
 .../frontend/src/components/MkPostForm.vue    | 20 +++++++++++++++----
 packages/misskey-js/src/autogen/types.ts      |  3 ++-
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7d48d14c71..4b35034cc8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,9 @@
 - Fix: リアクションしたユーザー一覧のユーザー名がはみ出る問題を修正  
   (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/672)
 - Fix: `/share`ページにおいて絵文字ピッカーを開くことができない問題を修正
+- Fix: ダイレクト投稿の"削除して編集"において、宛先が保持されていなかった問題を修正
+- Fix: 投稿フォームへのURL貼り付けによる引用が下書きに保存されていなかった問題を修正
+- Fix: "削除して編集"や下書きにおいて、リアクションの受け入れ設定が保持/保存されていなかった問題を修正
 
 ### Server
 - Feat: レートリミット制限に引っかかったときに`Retry-After`ヘッダーを返すように (#13949)
diff --git a/packages/backend/src/models/json-schema/note.ts b/packages/backend/src/models/json-schema/note.ts
index 2641161c8b..61f62dce60 100644
--- a/packages/backend/src/models/json-schema/note.ts
+++ b/packages/backend/src/models/json-schema/note.ts
@@ -204,6 +204,7 @@ export const packedNoteSchema = {
 		reactionAcceptance: {
 			type: 'string',
 			optional: false, nullable: true,
+			enum: ['likeOnly', 'likeOnlyForRemote', 'nonSensitiveOnly', 'nonSensitiveOnlyForLocalLikeOnlyForRemote'],
 		},
 		reactionEmojis: {
 			type: 'object',
diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue
index d057d197ec..64ad60ae85 100644
--- a/packages/frontend/src/components/MkPostForm.vue
+++ b/packages/frontend/src/components/MkPostForm.vue
@@ -367,6 +367,8 @@ function watchForDraft() {
 	watch(files, () => saveDraft(), { deep: true });
 	watch(visibility, () => saveDraft());
 	watch(localOnly, () => saveDraft());
+	watch(quoteId, () => saveDraft());
+	watch(reactionAcceptance, () => saveDraft());
 }
 
 function checkMissingMention() {
@@ -703,6 +705,8 @@ function saveDraft() {
 			files: files.value,
 			poll: poll.value,
 			visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(x => x.id) : undefined,
+			quoteId: quoteId.value,
+			reactionAcceptance: reactionAcceptance.value,
 		},
 	};
 
@@ -991,6 +995,8 @@ onMounted(() => {
 						users.forEach(u => pushVisibleUser(u));
 					});
 				}
+				quoteId.value = draft.data.quoteId;
+				reactionAcceptance.value = draft.data.reactionAcceptance;
 			}
 		}
 
@@ -998,9 +1004,11 @@ onMounted(() => {
 		if (props.initialNote) {
 			const init = props.initialNote;
 			text.value = init.text ? init.text : '';
-			files.value = init.files ?? [];
-			cw.value = init.cw ?? null;
 			useCw.value = init.cw != null;
+			cw.value = init.cw ?? null;
+			visibility.value = init.visibility;
+			localOnly.value = init.localOnly ?? false;
+			files.value = init.files ?? [];
 			if (init.poll) {
 				poll.value = {
 					choices: init.poll.choices.map(x => x.text),
@@ -1009,9 +1017,13 @@ onMounted(() => {
 					expiredAfter: null,
 				};
 			}
-			visibility.value = init.visibility;
-			localOnly.value = init.localOnly ?? false;
+			if (init.visibleUserIds) {
+				misskeyApi('users/show', { userIds: init.visibleUserIds }).then(users => {
+					users.forEach(u => pushVisibleUser(u));
+				});
+			}
 			quoteId.value = init.renote ? init.renote.id : null;
+			reactionAcceptance.value = init.reactionAcceptance;
 		}
 
 		nextTick(() => watchForDraft());
diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts
index d3c857219b..b2b8938baa 100644
--- a/packages/misskey-js/src/autogen/types.ts
+++ b/packages/misskey-js/src/autogen/types.ts
@@ -4089,7 +4089,8 @@ export type components = {
         userId: string | null;
       }) | null;
       localOnly?: boolean;
-      reactionAcceptance: string | null;
+      /** @enum {string|null} */
+      reactionAcceptance: 'likeOnly' | 'likeOnlyForRemote' | 'nonSensitiveOnly' | 'nonSensitiveOnlyForLocalLikeOnlyForRemote';
       reactionEmojis: {
         [key: string]: string;
       };