予約投稿の一覧表示、削除をできるようにした

dbに投稿内容を保存するようにした

Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
This commit is contained in:
mattyatea 2023-11-09 16:09:51 +09:00
parent 14b48f87d8
commit 540f531b6d
No known key found for this signature in database
GPG key ID: 068E54E2C33BEF9A
15 changed files with 238 additions and 25 deletions

View file

@ -20,6 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div v-if="mock">
<MkTime :time="note.createdAt" colored/>
</div>
<MkTime v-else-if="note.isSchedule" mode="absolute" :time="note.createdAt" colored/>
<MkA v-else :to="notePage(note)">
<MkTime :time="note.createdAt" colored/>
</MkA>
@ -42,7 +43,8 @@ import { notePage } from '@/filters/note.js';
import { userPage } from '@/filters/user.js';
defineProps<{
note: Misskey.entities.Note;
note: Misskey.entities.Note & {isSchedule? : boolean};
scheduled?: boolean;
}>();
const mock = inject<boolean>('mock', false);

View file

@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<div :class="$style.root">
<div v-show="!isDeleted" :class="$style.root" :tabindex="!isDeleted ? '-1' : undefined">
<MkAvatar :class="$style.avatar" :user="note.user" link preview/>
<div :class="$style.main">
<MkNoteHeader :class="$style.header" :note="note" :mini="true"/>
@ -16,23 +16,40 @@ SPDX-License-Identifier: AGPL-3.0-only
<div v-show="note.cw == null || showContent">
<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 danger @click="deleteScheduleNote()">{{ i18n.ts.delete }}</MkButton>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { } from 'vue';
import * as Misskey from 'misskey-js';
import { ref } from 'vue';
import { i18n } from '../i18n.js';
import MkNoteHeader from '@/components/MkNoteHeader.vue';
import MkSubNoteContent from '@/components/MkSubNoteContent.vue';
import MkCwButton from '@/components/MkCwButton.vue';
import { $i } from '@/account.js';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
const isDeleted = ref(false);
const props = defineProps<{
note: Misskey.entities.Note;
note: Misskey.entities.Note & {isSchedule? : boolean};
}>();
async function deleteScheduleNote() {
await os.apiWithDialog('notes/delete-schedule', { noteId: props.note.id })
.then(() => {
isDeleted.value = true;
});
}
function editScheduleNote(id) {
}
const showContent = $ref(false);
</script>
@ -42,8 +59,12 @@ const showContent = $ref(false);
margin: 0;
padding: 0;
font-size: 0.95em;
border-bottom: solid 0.5px var(--divider);
}
.button{
margin-right: var(--margin);
margin-bottom: var(--margin);
}
.avatar {
flex-shrink: 0;
display: block;

View file

@ -19,6 +19,8 @@ SPDX-License-Identifier: AGPL-3.0-only
</button>
</div>
<div :class="$style.headerRight">
<button v-tooltip="i18n.ts.schedulePost" class="_button" :class="[$style.headerRightItem, { [$style.headerRightButtonActive]: schedule }]" @click="toggleSchedule"><i class="ti ti-calendar-time"></i></button>
<button v-tooltip="i18n.ts.schedulePostList" class="_button" :class="[$style.headerRightItem]" @click="listSchedulePost"><i class="ti ti-calendar-event"></i></button>
<template v-if="!(channel != null && fixed)">
<button v-if="channel == null" ref="visibilityButton" v-click-anime v-tooltip="i18n.ts.visibility" :class="['_button', $style.headerRightItem, $style.visibility]" @click="setVisibility">
<span v-if="visibility === 'public'"><i class="ti ti-world"></i></span>
@ -81,7 +83,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<div :class="$style.footerLeft">
<button v-tooltip="i18n.ts.attachFile" class="_button" :class="$style.footerButton" @click="chooseFileFrom"><i class="ti ti-photo-plus"></i></button>
<button v-tooltip="i18n.ts.poll" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: poll }]" @click="togglePoll"><i class="ti ti-chart-arrows"></i></button>
<button v-tooltip="i18n.ts.schedule" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: schedule }]" @click="toggleSchedule"><i class="ti ti-calendar-event"></i></button>
<button v-tooltip="i18n.ts.useCw" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: useCw }]" @click="useCw = !useCw"><i class="ti ti-eye-off"></i></button>
<button v-tooltip="i18n.ts.mention" class="_button" :class="$style.footerButton" @click="insertMention"><i class="ti ti-at"></i></button>
<button v-tooltip="i18n.ts.hashtags" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: withHashtags }]" @click="withHashtags = !withHashtags"><i class="ti ti-hash"></i></button>
@ -127,6 +128,7 @@ import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { miLocalStorage } from '@/local-storage.js';
import { claimAchievement } from '@/scripts/achievements.js';
import MkScheduleEditor from '@/components/MkScheduleEditor.vue';
import { listSchedulePost } from '@/os.js';
const modal = inject('modal');
@ -1061,6 +1063,10 @@ defineExpose({
background: none;
}
&.headerRightButtonActive {
color: var(--accent);
}
&.danger {
color: #ff2a2a;
}
@ -1214,6 +1220,7 @@ defineExpose({
grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
grid-auto-rows: 40px;
direction: rtl;
}
.footerButton {

View file

@ -0,0 +1,50 @@
<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkModalWindow
ref="dialogEl"
:withOkButton="false"
@click="cancel()"
@close="cancel()"
@closed="$emit('closed')"
>
<template #header> 予約投稿一覧</template>
<div v-for="item in notes">
<MkSpacer :marginMin="14" :marginMax="16">
<MkNoteSimple scheduled="true" :note="item.note"/>
</MkSpacer>
</div>
</MkModalWindow>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js';
import MkModalWindow from '@/components/MkModalWindow.vue';
import * as os from '@/os.js';
import MkNoteSimple from '@/components/MkNoteSimple.vue';
import MkSignin from '@/components/MkSignin.vue';
const emit = defineEmits<{
(ev: 'ok', selected: Misskey.entities.UserDetailed): void;
(ev: 'cancel'): void;
(ev: 'closed'): void;
}>();
let dialogEl = $ref();
const notes = ref([]);
const cancel = () => {
emit('cancel');
dialogEl.close();
};
onMounted(async () => {
notes.value = await os.api('notes/list-schedule');
});
</script>
<style lang="scss" module>
</style>