2023-07-27 08:31:52 +03:00
|
|
|
|
<!--
|
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
-->
|
|
|
|
|
|
2022-07-05 16:40:15 +03:00
|
|
|
|
<template>
|
|
|
|
|
<MkStickyContainer>
|
2022-06-20 11:38:49 +03:00
|
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-19 10:20:53 +03:00
|
|
|
|
<MkSpacer :contentMax="800">
|
|
|
|
|
<div>
|
2023-04-01 07:42:40 +03:00
|
|
|
|
<Transition :name="defaultStore.state.animation ? 'fade' : ''" mode="out-in">
|
2023-05-19 10:20:53 +03:00
|
|
|
|
<div v-if="note">
|
2023-01-05 14:04:56 +02:00
|
|
|
|
<div v-if="showNext" class="_margin">
|
2023-09-24 05:21:03 +03:00
|
|
|
|
<MkNotes class="" :pagination="nextPagination" :noGap="true" :disableAutoLoad="true"/>
|
2021-09-17 16:39:15 +03:00
|
|
|
|
</div>
|
2022-07-05 16:40:15 +03:00
|
|
|
|
|
2023-05-19 10:20:53 +03:00
|
|
|
|
<div class="_margin">
|
2023-09-01 03:36:19 +03:00
|
|
|
|
<MkButton v-if="!showNext" :class="$style.loadNext" @click="showNext = true"><i class="ti ti-chevron-up"></i></MkButton>
|
2023-05-19 10:20:53 +03:00
|
|
|
|
<div class="_margin _gaps_s">
|
2022-07-05 16:40:15 +03:00
|
|
|
|
<MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri"/>
|
2023-05-19 10:20:53 +03:00
|
|
|
|
<MkNoteDetailed :key="note.id" v-model:note="note" :class="$style.note"/>
|
2022-07-05 16:40:15 +03:00
|
|
|
|
</div>
|
2023-05-19 10:20:53 +03:00
|
|
|
|
<div v-if="clips && clips.length > 0" class="_margin">
|
|
|
|
|
<div style="font-weight: bold; padding: 12px;">{{ i18n.ts.clip }}</div>
|
2023-03-17 08:09:43 +02:00
|
|
|
|
<div class="_gaps">
|
|
|
|
|
<MkA v-for="item in clips" :key="item.id" :to="`/clips/${item.id}`">
|
|
|
|
|
<MkClipPreview :clip="item"/>
|
|
|
|
|
</MkA>
|
|
|
|
|
</div>
|
2022-07-05 16:40:15 +03:00
|
|
|
|
</div>
|
2023-09-01 03:36:19 +03:00
|
|
|
|
<MkButton v-if="!showPrev" :class="$style.loadPrev" @click="showPrev = true"><i class="ti ti-chevron-down"></i></MkButton>
|
2021-09-17 16:39:15 +03:00
|
|
|
|
</div>
|
2020-02-16 15:15:49 +02:00
|
|
|
|
|
2023-01-05 14:04:56 +02:00
|
|
|
|
<div v-if="showPrev" class="_margin">
|
2023-05-19 10:20:53 +03:00
|
|
|
|
<MkNotes class="" :pagination="prevPagination" :noGap="true"/>
|
2022-07-05 16:40:15 +03:00
|
|
|
|
</div>
|
2021-09-17 16:39:15 +03:00
|
|
|
|
</div>
|
2023-02-12 09:52:48 +02:00
|
|
|
|
<MkError v-else-if="error" @retry="fetchNote()"/>
|
2022-07-05 16:40:15 +03:00
|
|
|
|
<MkLoading v-else/>
|
2022-12-30 06:37:14 +02:00
|
|
|
|
</Transition>
|
2022-07-05 16:40:15 +03:00
|
|
|
|
</div>
|
|
|
|
|
</MkSpacer>
|
|
|
|
|
</MkStickyContainer>
|
2020-01-29 21:37:25 +02:00
|
|
|
|
</template>
|
|
|
|
|
|
2022-06-20 11:38:49 +03:00
|
|
|
|
<script lang="ts" setup>
|
2023-12-07 07:42:09 +02:00
|
|
|
|
import { computed, watch, ref } from 'vue';
|
2023-09-04 07:33:38 +03:00
|
|
|
|
import * as Misskey from 'misskey-js';
|
2023-03-31 08:14:30 +03:00
|
|
|
|
import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
|
2023-02-22 04:00:34 +02:00
|
|
|
|
import MkNotes from '@/components/MkNotes.vue';
|
2022-08-30 18:24:33 +03:00
|
|
|
|
import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
|
2022-09-06 12:21:49 +03:00
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2024-01-04 11:32:46 +02:00
|
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 10:37:43 +03:00
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
|
import { dateString } from '@/filters/date.js';
|
2023-03-17 08:09:43 +02:00
|
|
|
|
import MkClipPreview from '@/components/MkClipPreview.vue';
|
2023-09-19 10:37:43 +03:00
|
|
|
|
import { defaultStore } from '@/store.js';
|
2022-06-20 11:38:49 +03:00
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
noteId: string;
|
|
|
|
|
}>();
|
|
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
|
const note = ref<null | Misskey.entities.Note>();
|
2023-12-26 07:19:35 +02:00
|
|
|
|
const clips = ref<Misskey.entities.Clip[]>();
|
2023-12-07 07:42:09 +02:00
|
|
|
|
const showPrev = ref(false);
|
|
|
|
|
const showNext = ref(false);
|
|
|
|
|
const error = ref();
|
2022-06-20 11:38:49 +03:00
|
|
|
|
|
|
|
|
|
const prevPagination = {
|
|
|
|
|
endpoint: 'users/notes' as const,
|
|
|
|
|
limit: 10,
|
2023-12-07 07:42:09 +02:00
|
|
|
|
params: computed(() => note.value ? ({
|
|
|
|
|
userId: note.value.userId,
|
|
|
|
|
untilId: note.value.id,
|
2022-06-20 11:38:49 +03:00
|
|
|
|
}) : null),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const nextPagination = {
|
|
|
|
|
reversed: true,
|
|
|
|
|
endpoint: 'users/notes' as const,
|
|
|
|
|
limit: 10,
|
2023-12-07 07:42:09 +02:00
|
|
|
|
params: computed(() => note.value ? ({
|
|
|
|
|
userId: note.value.userId,
|
|
|
|
|
sinceId: note.value.id,
|
2022-06-20 11:38:49 +03:00
|
|
|
|
}) : null),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function fetchNote() {
|
2023-12-07 07:42:09 +02:00
|
|
|
|
showPrev.value = false;
|
|
|
|
|
showNext.value = false;
|
|
|
|
|
note.value = null;
|
2024-01-04 11:32:46 +02:00
|
|
|
|
misskeyApi('notes/show', {
|
2022-06-20 11:38:49 +03:00
|
|
|
|
noteId: props.noteId,
|
|
|
|
|
}).then(res => {
|
2023-12-07 07:42:09 +02:00
|
|
|
|
note.value = res;
|
2023-09-17 04:55:26 +03:00
|
|
|
|
// 古いノートは被クリップ数をカウントしていないので、2023-10-01以前のものは強制的にnotes/clipsを叩く
|
2023-12-07 07:42:09 +02:00
|
|
|
|
if (note.value.clippedCount > 0 || new Date(note.value.createdAt).getTime() < new Date('2023-10-01').getTime()) {
|
2024-01-04 11:32:46 +02:00
|
|
|
|
misskeyApi('notes/clips', {
|
2023-12-07 07:42:09 +02:00
|
|
|
|
noteId: note.value.id,
|
2023-09-17 04:55:26 +03:00
|
|
|
|
}).then((_clips) => {
|
2023-12-07 07:42:09 +02:00
|
|
|
|
clips.value = _clips;
|
2023-09-17 04:55:26 +03:00
|
|
|
|
});
|
|
|
|
|
}
|
2022-06-20 11:38:49 +03:00
|
|
|
|
}).catch(err => {
|
2023-12-07 07:42:09 +02:00
|
|
|
|
error.value = err;
|
2022-06-20 11:38:49 +03:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(() => props.noteId, fetchNote, {
|
|
|
|
|
immediate: true,
|
2020-01-29 21:37:25 +02:00
|
|
|
|
});
|
2022-06-20 11:38:49 +03:00
|
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
|
const headerActions = computed(() => []);
|
2022-06-20 11:38:49 +03:00
|
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
|
const headerTabs = computed(() => []);
|
2022-06-20 11:38:49 +03:00
|
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
|
definePageMetadata(computed(() => note.value ? {
|
2022-06-20 11:38:49 +03:00
|
|
|
|
title: i18n.ts.note,
|
2023-12-07 07:42:09 +02:00
|
|
|
|
subtitle: dateString(note.value.createdAt),
|
|
|
|
|
avatar: note.value.user,
|
|
|
|
|
path: `/notes/${note.value.id}`,
|
2022-06-20 11:38:49 +03:00
|
|
|
|
share: {
|
2023-12-07 07:42:09 +02:00
|
|
|
|
title: i18n.t('noteOf', { user: note.value.user.name }),
|
|
|
|
|
text: note.value.text,
|
2022-06-20 11:38:49 +03:00
|
|
|
|
},
|
|
|
|
|
} : null));
|
2020-01-29 21:37:25 +02:00
|
|
|
|
</script>
|
2020-10-17 14:12:00 +03:00
|
|
|
|
|
2023-05-19 10:20:53 +03:00
|
|
|
|
<style lang="scss" module>
|
2021-04-17 05:40:47 +03:00
|
|
|
|
.fade-enter-active,
|
|
|
|
|
.fade-leave-active {
|
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
|
}
|
|
|
|
|
.fade-enter-from,
|
|
|
|
|
.fade-leave-to {
|
|
|
|
|
opacity: 0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 10:20:53 +03:00
|
|
|
|
.loadNext,
|
|
|
|
|
.loadPrev {
|
|
|
|
|
min-width: 0;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.loadNext {
|
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.loadPrev {
|
|
|
|
|
margin-top: var(--margin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.note {
|
|
|
|
|
border-radius: var(--radius);
|
|
|
|
|
background: var(--panel);
|
2020-10-17 14:12:00 +03:00
|
|
|
|
}
|
|
|
|
|
</style>
|