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')" > - +