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;
"willBePostedAtX": string;
"deleteAreYouSure": string;
"deleteAndEditConfirm": string;
};
}
declare const locales: {

View file

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

View file

@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSubNoteContent :class="$style.text" :note="note"/>
</div>
<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>
</div>
</div>
@ -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);

View file

@ -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),

View file

@ -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() {

View file

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