2022-07-05 15:40:15 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header
|
|
|
|
><MkPageHeader
|
|
|
|
:actions="headerActions"
|
|
|
|
:tabs="headerTabs"
|
|
|
|
:display-back-button="true"
|
2023-05-18 03:54:37 +02:00
|
|
|
:to="`#${noteId}`"
|
2023-04-08 02:01:42 +02:00
|
|
|
/></template>
|
|
|
|
<MkSpacer :content-max="800" :marginMin="6">
|
|
|
|
<div class="fcuexfpr">
|
|
|
|
<transition
|
|
|
|
:name="$store.state.animation ? 'fade' : ''"
|
|
|
|
mode="out-in"
|
|
|
|
>
|
2023-05-29 02:20:53 +02:00
|
|
|
<div v-if="appearNote" class="note">
|
2023-04-08 02:01:42 +02:00
|
|
|
<div v-if="showNext" class="_gap">
|
|
|
|
<XNotes
|
|
|
|
class="_content"
|
|
|
|
:pagination="nextPagination"
|
|
|
|
:no-gap="true"
|
|
|
|
/>
|
2022-07-05 15:40:15 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
|
|
|
|
<div class="main _gap">
|
|
|
|
<MkButton
|
|
|
|
v-if="!showNext && hasNext"
|
|
|
|
class="load next"
|
|
|
|
@click="showNext = true"
|
2023-05-21 22:30:35 +02:00
|
|
|
>
|
|
|
|
<i class="ph-caret-up ph-bold ph-lg"></i>
|
|
|
|
{{ `${i18n.ts.loadMore} (${i18n.ts.newer})` }}
|
|
|
|
</MkButton>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="note _gap">
|
|
|
|
<MkRemoteCaution
|
2023-05-29 02:20:53 +02:00
|
|
|
v-if="appearNote.user.host != null"
|
|
|
|
:href="appearNote.url ?? appearNote.uri"
|
2023-04-08 02:01:42 +02:00
|
|
|
/>
|
|
|
|
<XNoteDetailed
|
2023-05-29 02:20:53 +02:00
|
|
|
:key="appearNote.id"
|
|
|
|
v-model:note="appearNote"
|
2023-04-08 02:01:42 +02:00
|
|
|
class="note"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<MkButton
|
|
|
|
v-if="!showPrev && hasPrev"
|
|
|
|
class="load prev"
|
|
|
|
@click="showPrev = true"
|
2023-05-21 22:30:35 +02:00
|
|
|
>
|
|
|
|
<i class="ph-caret-down ph-bold ph-lg"></i>
|
|
|
|
{{ `${i18n.ts.loadMore} (${i18n.ts.older})` }}
|
|
|
|
</MkButton>
|
2022-07-05 15:40:15 +02:00
|
|
|
</div>
|
2020-02-16 14:15:49 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
<div v-if="showPrev" class="_gap">
|
|
|
|
<XNotes
|
|
|
|
class="_content"
|
|
|
|
:pagination="prevPagination"
|
|
|
|
:no-gap="true"
|
|
|
|
/>
|
|
|
|
</div>
|
2022-07-05 15:40:15 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkError v-else-if="error" @retry="fetch()" />
|
|
|
|
<MkLoading v-else />
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { computed, defineComponent, watch } from "vue";
|
|
|
|
import * as misskey from "calckey-js";
|
|
|
|
import XNoteDetailed from "@/components/MkNoteDetailed.vue";
|
|
|
|
import XNotes from "@/components/MkNotes.vue";
|
|
|
|
import MkRemoteCaution from "@/components/MkRemoteCaution.vue";
|
|
|
|
import MkButton from "@/components/MkButton.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
|
|
|
import { i18n } from "@/i18n";
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
noteId: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let note = $ref<null | misskey.entities.Note>();
|
|
|
|
let hasPrev = $ref(false);
|
|
|
|
let hasNext = $ref(false);
|
|
|
|
let showPrev = $ref(false);
|
|
|
|
let showNext = $ref(false);
|
|
|
|
let error = $ref();
|
2023-05-29 02:20:53 +02:00
|
|
|
let isRenote = $ref(false);
|
|
|
|
let appearNote = $ref<null | misskey.entities.Note>();
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
const prevPagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "users/notes" as const,
|
2022-06-20 10:38:49 +02:00
|
|
|
limit: 10,
|
2023-04-08 02:01:42 +02:00
|
|
|
params: computed(() =>
|
2023-05-29 02:20:53 +02:00
|
|
|
appearNote
|
2023-04-08 02:01:42 +02:00
|
|
|
? {
|
2023-05-29 02:20:53 +02:00
|
|
|
userId: appearNote.userId,
|
|
|
|
untilId: appearNote.id,
|
2023-04-08 02:01:42 +02:00
|
|
|
}
|
|
|
|
: null
|
|
|
|
),
|
2022-06-20 10:38:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const nextPagination = {
|
|
|
|
reversed: true,
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "users/notes" as const,
|
2022-06-20 10:38:49 +02:00
|
|
|
limit: 10,
|
2023-04-08 02:01:42 +02:00
|
|
|
params: computed(() =>
|
2023-05-29 02:20:53 +02:00
|
|
|
appearNote
|
2023-04-08 02:01:42 +02:00
|
|
|
? {
|
2023-05-29 02:20:53 +02:00
|
|
|
userId: appearNote.userId,
|
|
|
|
sinceId: appearNote.id,
|
2023-04-08 02:01:42 +02:00
|
|
|
}
|
|
|
|
: null
|
|
|
|
),
|
2022-06-20 10:38:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function fetchNote() {
|
|
|
|
hasPrev = false;
|
|
|
|
hasNext = false;
|
|
|
|
showPrev = false;
|
|
|
|
showNext = false;
|
|
|
|
note = null;
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("notes/show", {
|
2022-06-20 10:38:49 +02:00
|
|
|
noteId: props.noteId,
|
2023-04-08 02:01:42 +02:00
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
note = res;
|
2023-05-29 02:20:53 +02:00
|
|
|
isRenote =
|
|
|
|
note.renote != null &&
|
|
|
|
note.text == null &&
|
|
|
|
note.fileIds.length === 0 &&
|
|
|
|
note.poll == null;
|
2023-05-29 05:14:08 +02:00
|
|
|
appearNote = isRenote
|
|
|
|
? (note.renote as misskey.entities.Note)
|
|
|
|
: note;
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
Promise.all([
|
|
|
|
os.api("users/notes", {
|
|
|
|
userId: note.userId,
|
|
|
|
untilId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
|
|
|
os.api("users/notes", {
|
|
|
|
userId: note.userId,
|
|
|
|
sinceId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
2023-05-19 19:02:41 +02:00
|
|
|
]).then(([prev, next]) => {
|
2023-04-08 02:01:42 +02:00
|
|
|
hasPrev = prev.length !== 0;
|
|
|
|
hasNext = next.length !== 0;
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
error = err;
|
2022-06-20 10:38:49 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(() => props.noteId, fetchNote, {
|
|
|
|
immediate: true,
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
definePageMetadata(
|
|
|
|
computed(() =>
|
2023-05-29 02:20:53 +02:00
|
|
|
appearNote
|
2023-04-08 02:01:42 +02:00
|
|
|
? {
|
2023-05-26 04:47:10 +02:00
|
|
|
title: i18n.t("noteOf", {
|
2023-05-29 02:20:53 +02:00
|
|
|
user: appearNote.user.name || appearNote.user.username,
|
2023-05-26 04:47:10 +02:00
|
|
|
}),
|
2023-05-29 02:20:53 +02:00
|
|
|
subtitle: new Date(appearNote.createdAt).toLocaleString(),
|
|
|
|
avatar: appearNote.user,
|
|
|
|
path: `/notes/${appearNote.id}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
share: {
|
2023-05-26 04:47:10 +02:00
|
|
|
title: i18n.t("noteOf", {
|
2023-05-29 05:14:08 +02:00
|
|
|
user:
|
|
|
|
appearNote.user.name ||
|
|
|
|
appearNote.user.username,
|
2023-05-26 04:47:10 +02:00
|
|
|
}),
|
2023-05-29 02:20:53 +02:00
|
|
|
text: appearNote.text,
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
: null
|
|
|
|
)
|
|
|
|
);
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-17 04:40:47 +02:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
.fcuexfpr {
|
2023-05-12 02:52:30 +02:00
|
|
|
#calckey_app > :not(.wallpaper) & {
|
|
|
|
background: var(--bg);
|
|
|
|
}
|
2021-08-16 08:21:58 +02:00
|
|
|
|
2021-10-23 16:22:20 +02:00
|
|
|
> .note {
|
|
|
|
> .main {
|
|
|
|
> .load {
|
|
|
|
min-width: 0;
|
|
|
|
margin: 0 auto;
|
|
|
|
border-radius: 999px;
|
2020-11-17 06:59:15 +01:00
|
|
|
|
2021-10-23 16:22:20 +02:00
|
|
|
&.next {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
2020-11-17 06:59:15 +01:00
|
|
|
|
2021-10-23 16:22:20 +02:00
|
|
|
&.prev {
|
|
|
|
margin-top: var(--margin);
|
2020-11-17 06:59:15 +01:00
|
|
|
}
|
2021-10-23 16:22:20 +02:00
|
|
|
}
|
2020-11-17 06:59:15 +01:00
|
|
|
|
2021-10-23 16:22:20 +02:00
|
|
|
> .note {
|
2021-08-16 08:21:58 +02:00
|
|
|
> .note {
|
2021-10-23 16:22:20 +02:00
|
|
|
border-radius: var(--radius);
|
|
|
|
background: var(--panel);
|
2021-08-16 08:21:58 +02:00
|
|
|
}
|
2021-10-23 16:22:20 +02:00
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|