2022-07-05 08:40:15 -05:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2022-06-20 03:38:49 -05:00
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-07-05 08:40:15 -05:00
|
|
|
<MkSpacer :content-max="800">
|
|
|
|
<div class="fcuexfpr">
|
2022-12-29 22:37:14 -06:00
|
|
|
<Transition :name="$store.state.animation ? 'fade' : ''" mode="out-in">
|
2022-07-05 08:40:15 -05:00
|
|
|
<div v-if="note" class="note">
|
2023-01-05 06:04:56 -06:00
|
|
|
<div v-if="showNext" class="_margin">
|
2023-02-21 20:00:34 -06:00
|
|
|
<MkNotes class="" :pagination="nextPagination" :no-gap="true"/>
|
2021-09-17 08:39:15 -05:00
|
|
|
</div>
|
2022-07-05 08:40:15 -05:00
|
|
|
|
2023-01-05 06:04:56 -06:00
|
|
|
<div class="main _margin">
|
2022-12-19 04:01:30 -06:00
|
|
|
<MkButton v-if="!showNext && hasNext" class="load next" @click="showNext = true"><i class="ti ti-chevron-up"></i></MkButton>
|
2023-01-07 02:39:24 -06:00
|
|
|
<div class="note _margin _gaps_s">
|
2022-07-05 08:40:15 -05:00
|
|
|
<MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri"/>
|
|
|
|
<XNoteDetailed :key="note.id" v-model:note="note" class="note"/>
|
|
|
|
</div>
|
2023-01-05 18:41:14 -06:00
|
|
|
<div v-if="clips && clips.length > 0" class="clips _margin">
|
2022-07-20 08:24:26 -05:00
|
|
|
<div class="title">{{ i18n.ts.clip }}</div>
|
2023-03-17 01:09:43 -05: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 08:40:15 -05:00
|
|
|
</div>
|
2022-12-19 04:01:30 -06:00
|
|
|
<MkButton v-if="!showPrev && hasPrev" class="load prev" @click="showPrev = true"><i class="ti ti-chevron-down"></i></MkButton>
|
2021-09-17 08:39:15 -05:00
|
|
|
</div>
|
2020-02-16 07:15:49 -06:00
|
|
|
|
2023-01-05 06:04:56 -06:00
|
|
|
<div v-if="showPrev" class="_margin">
|
2023-02-21 20:00:34 -06:00
|
|
|
<MkNotes class="" :pagination="prevPagination" :no-gap="true"/>
|
2022-07-05 08:40:15 -05:00
|
|
|
</div>
|
2021-09-17 08:39:15 -05:00
|
|
|
</div>
|
2023-02-12 01:52:48 -06:00
|
|
|
<MkError v-else-if="error" @retry="fetchNote()"/>
|
2022-07-05 08:40:15 -05:00
|
|
|
<MkLoading v-else/>
|
2022-12-29 22:37:14 -06:00
|
|
|
</Transition>
|
2022-07-05 08:40:15 -05:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 13:37:25 -06:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
<script lang="ts" setup>
|
2023-02-16 08:09:41 -06:00
|
|
|
import { computed, watch } from 'vue';
|
2022-06-20 03:38:49 -05:00
|
|
|
import * as misskey from 'misskey-js';
|
2022-08-30 10:24:33 -05:00
|
|
|
import XNoteDetailed from '@/components/MkNoteDetailed.vue';
|
2023-02-21 20:00:34 -06:00
|
|
|
import MkNotes from '@/components/MkNotes.vue';
|
2022-08-30 10:24:33 -05:00
|
|
|
import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
2022-06-20 03:38:49 -05:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
import { i18n } from '@/i18n';
|
2023-01-01 02:11:33 -06:00
|
|
|
import { dateString } from '@/filters/date';
|
2023-03-17 01:09:43 -05:00
|
|
|
import MkClipPreview from '@/components/MkClipPreview.vue';
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
noteId: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let note = $ref<null | misskey.entities.Note>();
|
|
|
|
let clips = $ref();
|
|
|
|
let hasPrev = $ref(false);
|
|
|
|
let hasNext = $ref(false);
|
|
|
|
let showPrev = $ref(false);
|
|
|
|
let showNext = $ref(false);
|
|
|
|
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() {
|
|
|
|
hasPrev = false;
|
|
|
|
hasNext = false;
|
|
|
|
showPrev = false;
|
|
|
|
showNext = false;
|
|
|
|
note = null;
|
|
|
|
os.api('notes/show', {
|
|
|
|
noteId: props.noteId,
|
|
|
|
}).then(res => {
|
|
|
|
note = res;
|
|
|
|
Promise.all([
|
|
|
|
os.api('notes/clips', {
|
|
|
|
noteId: note.id,
|
|
|
|
}),
|
|
|
|
os.api('users/notes', {
|
|
|
|
userId: note.userId,
|
|
|
|
untilId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
|
|
|
os.api('users/notes', {
|
|
|
|
userId: note.userId,
|
|
|
|
sinceId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
|
|
|
]).then(([_clips, prev, next]) => {
|
|
|
|
clips = _clips;
|
|
|
|
hasPrev = prev.length !== 0;
|
|
|
|
hasNext = next.length !== 0;
|
|
|
|
});
|
|
|
|
}).catch(err => {
|
|
|
|
error = err;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(() => props.noteId, fetchNote, {
|
|
|
|
immediate: true,
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => note ? {
|
|
|
|
title: i18n.ts.note,
|
2023-01-01 02:11:33 -06:00
|
|
|
subtitle: dateString(note.createdAt),
|
2022-06-20 03:38:49 -05:00
|
|
|
avatar: note.user,
|
|
|
|
path: `/notes/${note.id}`,
|
|
|
|
share: {
|
|
|
|
title: i18n.t('noteOf', { user: note.user.name }),
|
|
|
|
text: note.text,
|
|
|
|
},
|
|
|
|
} : null));
|
2020-01-29 13:37:25 -06:00
|
|
|
</script>
|
2020-10-17 06:12:00 -05:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-16 21:40:47 -05:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
.fcuexfpr {
|
2021-08-16 01:21:58 -05:00
|
|
|
background: var(--bg);
|
|
|
|
|
2021-10-23 09:22:20 -05:00
|
|
|
> .note {
|
|
|
|
> .main {
|
|
|
|
> .load {
|
|
|
|
min-width: 0;
|
|
|
|
margin: 0 auto;
|
|
|
|
border-radius: 999px;
|
2020-11-16 23:59:15 -06:00
|
|
|
|
2021-10-23 09:22:20 -05:00
|
|
|
&.next {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
2020-11-16 23:59:15 -06:00
|
|
|
|
2021-10-23 09:22:20 -05:00
|
|
|
&.prev {
|
|
|
|
margin-top: var(--margin);
|
2020-11-16 23:59:15 -06:00
|
|
|
}
|
2021-10-23 09:22:20 -05:00
|
|
|
}
|
2020-11-16 23:59:15 -06:00
|
|
|
|
2021-10-23 09:22:20 -05:00
|
|
|
> .note {
|
2021-08-16 01:21:58 -05:00
|
|
|
> .note {
|
2021-10-23 09:22:20 -05:00
|
|
|
border-radius: var(--radius);
|
|
|
|
background: var(--panel);
|
2021-08-16 01:21:58 -05:00
|
|
|
}
|
2021-10-23 09:22:20 -05:00
|
|
|
}
|
2021-08-16 01:21:58 -05:00
|
|
|
|
2021-10-23 09:22:20 -05:00
|
|
|
> .clips {
|
|
|
|
> .title {
|
|
|
|
font-weight: bold;
|
|
|
|
padding: 12px;
|
|
|
|
}
|
2020-10-17 06:12:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|