2022-06-20 02:38:49 -06:00
|
|
|
<template><MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<MkSpacer :content-max="800">
|
2021-10-23 08:22:20 -06:00
|
|
|
<div class="fcuexfpr">
|
2022-01-25 07:18:21 -07:00
|
|
|
<transition :name="$store.state.animation ? 'fade' : ''" mode="out-in">
|
2021-09-17 07:39:15 -06:00
|
|
|
<div v-if="note" class="note">
|
2021-11-19 03:36:12 -07:00
|
|
|
<div v-if="showNext" class="_gap">
|
2022-06-20 02:38:49 -06:00
|
|
|
<XNotes class="_content" :pagination="nextPagination" :no-gap="true"/>
|
2021-04-16 20:40:47 -06:00
|
|
|
</div>
|
2021-09-17 07:39:15 -06:00
|
|
|
|
|
|
|
<div class="main _gap">
|
|
|
|
<MkButton v-if="!showNext && hasNext" class="load next" @click="showNext = true"><i class="fas fa-chevron-up"></i></MkButton>
|
|
|
|
<div class="note _gap">
|
2022-02-25 04:03:17 -07:00
|
|
|
<MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri" class="_isolated"/>
|
2021-11-19 03:36:12 -07:00
|
|
|
<XNoteDetailed :key="note.id" v-model:note="note" class="_isolated note"/>
|
2021-09-17 07:39:15 -06:00
|
|
|
</div>
|
2021-11-19 03:36:12 -07:00
|
|
|
<div v-if="clips && clips.length > 0" class="_content clips _gap">
|
2021-09-17 07:39:15 -06:00
|
|
|
<div class="title">{{ $ts.clip }}</div>
|
|
|
|
<MkA v-for="item in clips" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
|
|
|
|
<b>{{ item.name }}</b>
|
|
|
|
<div v-if="item.description" class="description">{{ item.description }}</div>
|
|
|
|
<div class="user">
|
|
|
|
<MkAvatar :user="item.user" class="avatar" :show-indicator="true"/> <MkUserName :user="item.user" :nowrap="false"/>
|
|
|
|
</div>
|
|
|
|
</MkA>
|
|
|
|
</div>
|
|
|
|
<MkButton v-if="!showPrev && hasPrev" class="load prev" @click="showPrev = true"><i class="fas fa-chevron-down"></i></MkButton>
|
2021-04-16 20:40:47 -06:00
|
|
|
</div>
|
2020-02-16 06:15:49 -07:00
|
|
|
|
2021-11-19 03:36:12 -07:00
|
|
|
<div v-if="showPrev" class="_gap">
|
2022-06-20 02:38:49 -06:00
|
|
|
<XNotes class="_content" :pagination="prevPagination" :no-gap="true"/>
|
2021-09-17 07:39:15 -06:00
|
|
|
</div>
|
2021-04-16 20:40:47 -06:00
|
|
|
</div>
|
2021-09-17 07:39:15 -06:00
|
|
|
<MkError v-else-if="error" @retry="fetch()"/>
|
|
|
|
<MkLoading v-else/>
|
|
|
|
</transition>
|
|
|
|
</div>
|
2022-06-20 02:38:49 -06:00
|
|
|
</MkSpacer></MkStickyContainer>
|
2020-01-29 12:37:25 -07:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, defineComponent, watch } from 'vue';
|
|
|
|
import * as misskey from 'misskey-js';
|
2021-11-11 10:02:25 -07:00
|
|
|
import XNote from '@/components/note.vue';
|
|
|
|
import XNoteDetailed from '@/components/note-detailed.vue';
|
|
|
|
import XNotes from '@/components/notes.vue';
|
|
|
|
import MkRemoteCaution from '@/components/remote-caution.vue';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import * as os from '@/os';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
|
|
|
|
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 12:37:25 -07:00
|
|
|
});
|
2022-06-20 02:38:49 -06:00
|
|
|
|
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => note ? {
|
|
|
|
title: i18n.ts.note,
|
|
|
|
subtitle: new Date(note.createdAt).toLocaleString(),
|
|
|
|
avatar: note.user,
|
|
|
|
path: `/notes/${note.id}`,
|
|
|
|
share: {
|
|
|
|
title: i18n.t('noteOf', { user: note.user.name }),
|
|
|
|
text: note.text,
|
|
|
|
},
|
|
|
|
} : null));
|
2020-01-29 12:37:25 -07:00
|
|
|
</script>
|
2020-10-17 05:12:00 -06:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-16 20:40:47 -06:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
.fcuexfpr {
|
2021-08-16 00:21:58 -06:00
|
|
|
background: var(--bg);
|
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
> .note {
|
|
|
|
> .main {
|
|
|
|
> .load {
|
|
|
|
min-width: 0;
|
|
|
|
margin: 0 auto;
|
|
|
|
border-radius: 999px;
|
2020-11-16 22:59:15 -07:00
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
&.next {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
2020-11-16 22:59:15 -07:00
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
&.prev {
|
|
|
|
margin-top: var(--margin);
|
2020-11-16 22:59:15 -07:00
|
|
|
}
|
2021-10-23 08:22:20 -06:00
|
|
|
}
|
2020-11-16 22:59:15 -07:00
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
> .note {
|
2021-08-16 00:21:58 -06:00
|
|
|
> .note {
|
2021-10-23 08:22:20 -06:00
|
|
|
border-radius: var(--radius);
|
|
|
|
background: var(--panel);
|
2021-08-16 00:21:58 -06:00
|
|
|
}
|
2021-10-23 08:22:20 -06:00
|
|
|
}
|
2021-08-16 00:21:58 -06:00
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
> .clips {
|
|
|
|
> .title {
|
|
|
|
font-weight: bold;
|
|
|
|
padding: 12px;
|
|
|
|
}
|
2020-11-16 22:59:15 -07:00
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
> .item {
|
|
|
|
display: block;
|
|
|
|
padding: 16px;
|
2020-11-16 22:59:15 -07:00
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
> .description {
|
|
|
|
padding: 8px 0;
|
|
|
|
}
|
2020-11-16 22:59:15 -07:00
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
> .user {
|
|
|
|
$height: 32px;
|
|
|
|
padding-top: 16px;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
line-height: $height;
|
2020-11-16 22:59:15 -07:00
|
|
|
|
2021-10-23 08:22:20 -06:00
|
|
|
> .avatar {
|
|
|
|
width: $height;
|
|
|
|
height: $height;
|
2020-11-16 22:59:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|