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