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