From 28ee4d47c0b240db6eb30e14291e44862b1f7484 Mon Sep 17 00:00:00 2001 From: mattyatea Date: Sun, 26 Nov 2023 05:18:59 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=E4=BA=88=E7=B4=84=E6=8A=95=E7=A8=BF?= =?UTF-8?q?=E3=81=AE=E5=89=8A=E9=99=A4=E3=81=97=E3=81=A6=E7=B7=A8=E9=9B=86?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mattyatea --- locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + .../frontend/src/components/MkNoteSimple.vue | 24 +++++++++++++++++-- .../frontend/src/components/MkPostForm.vue | 5 ++++ .../src/components/MkScheduleEditor.vue | 6 +++-- .../components/MkSchedulePostListDialog.vue | 13 +++++----- 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index 60f09d8117..69b01f0a84 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -2494,6 +2494,7 @@ export interface Locale { "addSchedule": string; "willBePostedAtX": string; "deleteAreYouSure": string; + "deleteAndEditConfirm": string; }; } declare const locales: { diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 16c9fc5888..755d2715b0 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2382,3 +2382,4 @@ _schedulePost: addSchedule: "予約設定" willBePostedAtX: "{date}に投稿予約しました。" deleteAreYouSure: "予約投稿を削除しますか?" + deleteAndEditConfirm: "予約投稿を削除して編集しますか?" diff --git a/packages/frontend/src/components/MkNoteSimple.vue b/packages/frontend/src/components/MkNoteSimple.vue index e47429113f..8a130e95f5 100644 --- a/packages/frontend/src/components/MkNoteSimple.vue +++ b/packages/frontend/src/components/MkNoteSimple.vue @@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-only
- {{ i18n.ts.edit }} + {{ i18n.ts.deleteAndEdit }} {{ i18n.ts.delete }}
@@ -43,6 +43,10 @@ const props = defineProps<{ }; }>(); +const emit = defineEmits<{ + (ev: 'editScheduleNote'): void; +}>(); + async function deleteScheduleNote() { if (!props.note.isSchedule || !props.note.scheduledNoteId) return; @@ -58,8 +62,24 @@ async function deleteScheduleNote() { }); } -function editScheduleNote(id) { +async function editScheduleNote() { + if (!props.note.isSchedule || !props.note.scheduledNoteId) return; + const { canceled } = await os.confirm({ + type: 'warning', + text: i18n.ts._schedulePost.deleteAndEditConfirm, + }); + + if (canceled) return; + + await os.api('notes/schedule/delete', { scheduledNoteId: props.note.scheduledNoteId }) + .then(() => { + isDeleted.value = true; + }); + + await os.post({ initialNote: props.note, renote: props.note.renote, reply: props.note.reply, channel: props.note.channel }); + + emit('editScheduleNote'); } const showContent = $ref(false); diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 031b108db4..6f3fc7f3be 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -983,6 +983,11 @@ onMounted(() => { files = init.files; cw = init.cw; useCw = init.cw != null; + if (init.isSchedule) { + schedule = { + scheduledAt: init.createdAt, + }; + } if (init.poll) { poll = { choices: init.poll.choices.map(x => x.text), diff --git a/packages/frontend/src/components/MkScheduleEditor.vue b/packages/frontend/src/components/MkScheduleEditor.vue index b5083ad050..2035dcc450 100644 --- a/packages/frontend/src/components/MkScheduleEditor.vue +++ b/packages/frontend/src/components/MkScheduleEditor.vue @@ -37,8 +37,10 @@ const emit = defineEmits<{ const atDate = ref(formatDateTimeString(addTime(new Date(), 1, 'day'), 'yyyy-MM-dd')); const atTime = ref('00:00'); -if ( props.modelValue && props.modelValue.scheduledAt) { - atDate.value = atTime.value = props.modelValue.scheduledAt; +if ( props.modelValue.scheduledAt) { + const date = new Date(props.modelValue.scheduledAt); + atDate.value = formatDateTimeString(date, 'yyyy-MM-dd'); + atTime.value = formatDateTimeString(date, 'HH:mm'); } function get() { diff --git a/packages/frontend/src/components/MkSchedulePostListDialog.vue b/packages/frontend/src/components/MkSchedulePostListDialog.vue index 3ab9b7f683..23bcb6d25e 100644 --- a/packages/frontend/src/components/MkSchedulePostListDialog.vue +++ b/packages/frontend/src/components/MkSchedulePostListDialog.vue @@ -9,11 +9,10 @@ SPDX-License-Identifier: AGPL-3.0-only :withOkButton="false" @click="cancel()" @close="cancel()" - @closed="$emit('closed')" > - +