2024-04-15 03:16:57 +02:00
|
|
|
<template>
|
2024-04-22 09:38:51 +02:00
|
|
|
<ClientOnly>
|
2024-05-12 05:42:24 +02:00
|
|
|
<OverlayScrollbarsComponent v-if="loaded" :defer="true" class="max-h-dvh min-h-dvh overflow-y-auto pb-72">
|
|
|
|
|
<SocialElementsNotesNote v-for="note of context?.ancestors" :note="note" />
|
|
|
|
|
<div ref="element" class="first:rounded-t last:rounded-b overflow-hidden">
|
|
|
|
|
<SocialElementsNotesNote class="!rounded-none border-2 border-pink-500" v-if="note" :note="note" />
|
|
|
|
|
</div>
|
|
|
|
|
<SocialElementsNotesNote v-for="note of context?.descendants" :note="note" />
|
|
|
|
|
</OverlayScrollbarsComponent>
|
|
|
|
|
<OverlayScrollbarsComponent :defer="true" v-else class="max-h-dvh min-h-dvh overflow-y-auto">
|
|
|
|
|
<SocialElementsNotesNote v-for="_ of 5" :skeleton="true" />
|
|
|
|
|
</OverlayScrollbarsComponent>
|
2024-04-22 09:38:51 +02:00
|
|
|
</ClientOnly>
|
2024-04-15 03:16:57 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-05-12 05:42:24 +02:00
|
|
|
import { OverlayScrollbarsComponent } from "#imports";
|
2024-04-28 09:46:05 +02:00
|
|
|
definePageMeta({
|
|
|
|
|
layout: "app",
|
2024-04-29 01:48:03 +02:00
|
|
|
});
|
2024-04-15 03:16:57 +02:00
|
|
|
|
2024-05-12 05:42:24 +02:00
|
|
|
const element = ref<HTMLElement | null>(null);
|
2024-04-15 03:16:57 +02:00
|
|
|
const route = useRoute();
|
2024-04-27 03:28:12 +02:00
|
|
|
const client = useMegalodon();
|
2024-04-25 08:56:01 +02:00
|
|
|
const uuid = route.params.uuid as string;
|
2024-04-15 03:16:57 +02:00
|
|
|
|
2024-04-27 03:28:12 +02:00
|
|
|
const note = useNote(client, uuid);
|
2024-05-12 05:42:24 +02:00
|
|
|
const noteId = computed(() => note.value?.id ?? null);
|
|
|
|
|
const context = useNoteContext(client, noteId);
|
|
|
|
|
const loaded = computed(() => note.value !== null && context.value !== null);
|
|
|
|
|
|
|
|
|
|
// If ancestors changes, scroll down so that the initial note stays at the same place
|
|
|
|
|
watch(
|
|
|
|
|
[() => context.value?.ancestors, loaded],
|
|
|
|
|
async () => {
|
|
|
|
|
if (context.value?.ancestors.length === 0) return;
|
|
|
|
|
if (!loaded.value) return;
|
|
|
|
|
await nextTick();
|
|
|
|
|
// Wait for 200ms
|
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
|
|
|
element.value?.scrollIntoView({
|
|
|
|
|
behavior: "smooth",
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
immediate: true,
|
|
|
|
|
},
|
|
|
|
|
);
|
2024-04-26 07:54:02 +02:00
|
|
|
|
|
|
|
|
useServerSeoMeta({
|
2024-04-27 03:28:12 +02:00
|
|
|
title: note.value?.account.display_name,
|
|
|
|
|
description: note.value?.content,
|
|
|
|
|
ogImage: note.value?.media_attachments[0]?.preview_url,
|
2024-04-26 07:54:02 +02:00
|
|
|
});
|
2024-04-22 09:38:51 +02:00
|
|
|
</script>
|