Feat: 予約投稿の削除して編集を実装

Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
This commit is contained in:
mattyatea 2023-11-26 05:18:59 +09:00
parent c95cbbc9b6
commit 28ee4d47c0
No known key found for this signature in database
GPG Key ID: 068E54E2C33BEF9A
6 changed files with 40 additions and 10 deletions

1
locales/index.d.ts vendored
View File

@ -2494,6 +2494,7 @@ export interface Locale {
"addSchedule": string; "addSchedule": string;
"willBePostedAtX": string; "willBePostedAtX": string;
"deleteAreYouSure": string; "deleteAreYouSure": string;
"deleteAndEditConfirm": string;
}; };
} }
declare const locales: { declare const locales: {

View File

@ -2382,3 +2382,4 @@ _schedulePost:
addSchedule: "予約設定" addSchedule: "予約設定"
willBePostedAtX: "{date}に投稿予約しました。" willBePostedAtX: "{date}に投稿予約しました。"
deleteAreYouSure: "予約投稿を削除しますか?" deleteAreYouSure: "予約投稿を削除しますか?"
deleteAndEditConfirm: "予約投稿を削除して編集しますか?"

View File

@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSubNoteContent :class="$style.text" :note="note"/> <MkSubNoteContent :class="$style.text" :note="note"/>
</div> </div>
<div v-if="note.isSchedule" style="margin-top: 10px;"> <div v-if="note.isSchedule" style="margin-top: 10px;">
<MkButton :class="$style.button" inline @click="editScheduleNote(note.id)">{{ i18n.ts.edit }}</MkButton> <MkButton :class="$style.button" inline @click="editScheduleNote()">{{ i18n.ts.deleteAndEdit }}</MkButton>
<MkButton :class="$style.button" inline danger @click="deleteScheduleNote()">{{ i18n.ts.delete }}</MkButton> <MkButton :class="$style.button" inline danger @click="deleteScheduleNote()">{{ i18n.ts.delete }}</MkButton>
</div> </div>
</div> </div>
@ -43,6 +43,10 @@ const props = defineProps<{
}; };
}>(); }>();
const emit = defineEmits<{
(ev: 'editScheduleNote'): void;
}>();
async function deleteScheduleNote() { async function deleteScheduleNote() {
if (!props.note.isSchedule || !props.note.scheduledNoteId) return; 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); const showContent = $ref(false);

View File

@ -983,6 +983,11 @@ onMounted(() => {
files = init.files; files = init.files;
cw = init.cw; cw = init.cw;
useCw = init.cw != null; useCw = init.cw != null;
if (init.isSchedule) {
schedule = {
scheduledAt: init.createdAt,
};
}
if (init.poll) { if (init.poll) {
poll = { poll = {
choices: init.poll.choices.map(x => x.text), choices: init.poll.choices.map(x => x.text),

View File

@ -37,8 +37,10 @@ const emit = defineEmits<{
const atDate = ref(formatDateTimeString(addTime(new Date(), 1, 'day'), 'yyyy-MM-dd')); const atDate = ref(formatDateTimeString(addTime(new Date(), 1, 'day'), 'yyyy-MM-dd'));
const atTime = ref('00:00'); const atTime = ref('00:00');
if ( props.modelValue && props.modelValue.scheduledAt) { if ( props.modelValue.scheduledAt) {
atDate.value = atTime.value = 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() { function get() {

View File

@ -9,11 +9,10 @@ SPDX-License-Identifier: AGPL-3.0-only
:withOkButton="false" :withOkButton="false"
@click="cancel()" @click="cancel()"
@close="cancel()" @close="cancel()"
@closed="$emit('closed')"
> >
<template #header>{{ i18n.ts._schedulePost.list }}</template> <template #header>{{ i18n.ts._schedulePost.list }}</template>
<MkSpacer :marginMin="14" :marginMax="16"> <MkSpacer :marginMin="14" :marginMax="16">
<MkPagination :pagination="pagination"> <MkPagination ref="paginationEl" :pagination="pagination">
<template #empty> <template #empty>
<div class="_fullinfo"> <div class="_fullinfo">
<img :src="infoImageUrl" class="_ghost"/> <img :src="infoImageUrl" class="_ghost"/>
@ -23,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #default="{ items }"> <template #default="{ items }">
<div class="_gaps"> <div class="_gaps">
<MkNoteSimple v-for="item in items" :key="item.id" :scheduled="true" :note="item.note"/> <MkNoteSimple v-for="item in items" :key="item.id" :scheduled="true" :note="item.note" @editScheduleNote="listUpdate"/>
</div> </div>
</template> </template>
</MkPagination> </MkPagination>
@ -42,9 +41,7 @@ import { i18n } from '@/i18n.js';
import { infoImageUrl } from '@/instance.js'; import { infoImageUrl } from '@/instance.js';
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'ok', selected: Misskey.entities.UserDetailed): void;
(ev: 'cancel'): void; (ev: 'cancel'): void;
(ev: 'c-losed'): void;
}>(); }>();
const dialogEl = ref(); const dialogEl = ref();
@ -52,11 +49,15 @@ const cancel = () => {
emit('cancel'); emit('cancel');
dialogEl.value.close(); dialogEl.value.close();
}; };
const paginationEl = ref();
const pagination: Paging = { const pagination: Paging = {
endpoint: 'notes/schedule/list', endpoint: 'notes/schedule/list',
limit: 10, limit: 10,
}; };
function listUpdate() {
paginationEl.value.reload();
}
</script> </script>
<style lang="scss" module> <style lang="scss" module>