From d6fb3c3342da111520eda6b18837f17fb3b50b5e Mon Sep 17 00:00:00 2001
From: mattyatea <mattyacocacora0@gmail.com>
Date: Thu, 9 Nov 2023 18:35:47 +0900
Subject: [PATCH] =?UTF-8?q?=E5=9E=8B=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE?=
 =?UTF-8?q?=E6=AD=A3=E3=81=A8=E3=81=A1=E3=82=87=E3=81=A3=E3=81=A8=E3=81=97?=
 =?UTF-8?q?=E3=81=9F=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
---
 .../api/endpoints/notes/list-schedule.ts      | 65 +++++++++++++++----
 .../frontend/src/components/MkPostForm.vue    |  3 +-
 2 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/packages/backend/src/server/api/endpoints/notes/list-schedule.ts b/packages/backend/src/server/api/endpoints/notes/list-schedule.ts
index 8cd670e421..6efe8b6382 100644
--- a/packages/backend/src/server/api/endpoints/notes/list-schedule.ts
+++ b/packages/backend/src/server/api/endpoints/notes/list-schedule.ts
@@ -20,7 +20,31 @@ export const meta = {
 		items: {
 			type: 'object',
 			optional: false, nullable: false,
-			ref: 'Note',
+			properties: {
+				id: { type: 'string', optional: false, nullable: false },
+				note: {
+					type: 'object',
+					optional: false, nullable: false,
+					properties: {
+						id: { type: 'string', optional: false, nullable: false },
+						text: { type: 'string', optional: false, nullable: false },
+						files: { type: 'array', optional: false, nullable: false, items: { type: 'any' } },
+						localOnly: { type: 'boolean', optional: false, nullable: false },
+						visibility: { type: 'string', optional: false, nullable: false },
+						visibleUsers: { type: 'array', optional: false, nullable: false, items: { type: 'any' } },
+						reactionAcceptance: { type: 'string', optional: false, nullable: false },
+						user: {
+							type: 'object',
+							optional: false, nullable: false,
+							ref: 'User',
+						},
+						createdAt: { type: 'string', optional: false, nullable: false },
+						isSchedule: { type: 'boolean', optional: false, nullable: false },
+					},
+				},
+				userId: { type: 'string', optional: false, nullable: false },
+				expiresAt: { type: 'string', optional: false, nullable: false },
+			},
 		},
 	},
 	limit: {
@@ -33,10 +57,6 @@ export const meta = {
 } as const;
 
 export const paramDef = {
-	type: 'object',
-	properties: {
-	},
-	required: [],
 } as const;
 
 @Injectable()
@@ -49,13 +69,36 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 		super(meta, paramDef, async (ps, me) => {
 			const scheduleNotes = await this.noteScheduleRepository.findBy({ userId: me.id });
 			const user = await this.userEntityService.pack(me, me);
-			scheduleNotes.forEach((item: any) => {
-				item.note.user = user;
-				item.note.createdAt = new Date(item.expiresAt);
-				item.note.isSchedule = true;
-				item.note.id = item.id;
+			const scheduleNotesPack: {
+				id: string;
+				note: {
+					id: string;
+					text: string;
+					files: any[];
+					localOnly: boolean;
+					visibility: string;
+					visibleUsers: any[];
+					reactionAcceptance: string;
+					user: any;
+					createdAt: string;
+					isSchedule: boolean;
+				};
+				userId: string;
+				expiresAt: string;
+			}[] = scheduleNotes.map((item: any) => {
+				return {
+					...item,
+					note: {
+						...item.note,
+						user: user,
+						createdAt: new Date(item.expiresAt),
+						isSchedule: true,
+						id: item.id,
+					},
+				};
 			});
-			return scheduleNotes;
+
+			return scheduleNotesPack;
 		});
 	}
 }
diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue
index 66a7812448..6e2705f918 100644
--- a/packages/frontend/src/components/MkPostForm.vue
+++ b/packages/frontend/src/components/MkPostForm.vue
@@ -563,6 +563,7 @@ function removeVisibleUser(user) {
 
 function clear() {
 	text = '';
+	schedule = null;
 	files = [];
 	poll = null;
 	quoteId = null;
@@ -802,7 +803,7 @@ async function post(ev?: MouseEvent) {
 			if (notesCount === 1) {
 				claimAchievement('notes1');
 			}
-
+			poll = null;
 			const text = postData.text ?? '';
 			const lowerCase = text.toLowerCase();
 			if ((lowerCase.includes('love') || lowerCase.includes('❤')) && lowerCase.includes('misskey')) {