mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
feat: ✨ New notifications view, refactor all composables
This commit is contained in:
parent
7b8a02d49e
commit
e0c41bb9b5
|
|
@ -19,7 +19,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
const client = await useMegalodon();
|
const client = useMegalodon();
|
||||||
const instance = await useInstance(client);
|
const instance = useInstance(client);
|
||||||
const description = await useExtendedDescription(client);
|
const description = useExtendedDescription(client);
|
||||||
</script>
|
</script>
|
||||||
68
components/social-elements/notes/header.vue
Normal file
68
components/social-elements/notes/header.vue
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
<template>
|
||||||
|
<div v-if="small" class="flex flex-row">
|
||||||
|
<Skeleton :enabled="!note" shape="rect" class="!h-6 w-6">
|
||||||
|
<NuxtLink :href="accountUrl">
|
||||||
|
<img class="h-6 w-6 rounded ring-1 ring-white/5" :src="note?.account.avatar"
|
||||||
|
:alt="`${note?.account.acct}'s avatar`" />
|
||||||
|
</NuxtLink>
|
||||||
|
</Skeleton>
|
||||||
|
<div class="flex flex-col items-start justify-around ml-4 grow overflow-hidden">
|
||||||
|
<div class="flex flex-row text-sm items-center justify-between w-full">
|
||||||
|
<NuxtLink :href="accountUrl" class="font-semibold text-gray-200 line-clamp-1 break-all">
|
||||||
|
<Skeleton :enabled="!note" :min-width="90" :max-width="170" shape="rect">
|
||||||
|
{{
|
||||||
|
note?.account.display_name }}
|
||||||
|
</Skeleton>
|
||||||
|
</NuxtLink>
|
||||||
|
<NuxtLink :href="noteUrl" class="text-gray-400 ml-2 line-clamp-1 break-all shrink-0">
|
||||||
|
<Skeleton :enabled="!note" :min-width="50" :max-width="100" shape="rect">
|
||||||
|
{{ timeAgo }}
|
||||||
|
</Skeleton>
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="flex flex-row">
|
||||||
|
<Skeleton :enabled="!note" shape="rect" class="!h-12 w-12">
|
||||||
|
<NuxtLink :href="accountUrl">
|
||||||
|
<img class="h-12 w-12 rounded ring-1 ring-white/5" :src="note?.account.avatar"
|
||||||
|
:alt="`${note?.account.acct}'s avatar`" />
|
||||||
|
</NuxtLink>
|
||||||
|
</Skeleton>
|
||||||
|
<div class="flex flex-col items-start justify-around ml-4 grow overflow-hidden">
|
||||||
|
<div class="flex flex-row items-center justify-between w-full">
|
||||||
|
<NuxtLink :href="accountUrl" class="font-semibold text-gray-200 line-clamp-1 break-all">
|
||||||
|
<Skeleton :enabled="!note" :min-width="90" :max-width="170" shape="rect">
|
||||||
|
{{
|
||||||
|
note?.account.display_name }}
|
||||||
|
</Skeleton>
|
||||||
|
</NuxtLink>
|
||||||
|
<NuxtLink :href="noteUrl" class="text-gray-400 text-sm ml-2 line-clamp-1 break-all shrink-0">
|
||||||
|
<Skeleton :enabled="!note" :min-width="50" :max-width="100" shape="rect">
|
||||||
|
{{ timeAgo }}
|
||||||
|
</Skeleton>
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
<span class="text-gray-400 text-sm line-clamp-1 break-all w-full">
|
||||||
|
<Skeleton :enabled="!note" :min-width="130" :max-width="250" shape="rect">
|
||||||
|
@{{
|
||||||
|
note?.account.acct
|
||||||
|
}}
|
||||||
|
</Skeleton>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { Status } from '~/types/mastodon/status';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
note?: Status;
|
||||||
|
small?: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const noteUrl = props.note && `/@${props.note.account.acct}/${props.note.id}`;
|
||||||
|
const accountUrl = props.note && `/@${props.note.account.acct}`;
|
||||||
|
const timeAgo = useTimeAgo(props.note?.created_at ?? 0);
|
||||||
|
</script>
|
||||||
|
|
@ -1,49 +1,41 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="first:rounded-t last:rounded-b ring-1 ring-white/5 p-6 flex flex-col bg-dark-800 hover:bg-dark-700 duration-200">
|
class="first:rounded-t last:rounded-b ring-1 ring-white/5 p-6 flex flex-col bg-dark-800 hover:bg-dark-700 duration-200">
|
||||||
<div class="flex flex-row">
|
<div v-if="props.note?.reblog" class="mb-4 flex flex-row gap-2 items-center text-pink-500">
|
||||||
<Skeleton :enabled="isLoading" shape="rect" class="!h-12 w-12">
|
<Skeleton :enabled="!props.note" shape="rect" class="!h-6" :min-width="40" :max-width="100" width-unit="%">
|
||||||
<NuxtLink :href="accountUrl">
|
<Icon name="tabler:repeat" class="h-6 w-6" aria-hidden="true" />
|
||||||
<img class="h-12 w-12 rounded ring-1 ring-white/5" :src="note?.account.avatar"
|
<img v-if="props.note?.account.avatar" :src="props.note?.account.avatar"
|
||||||
:alt="`${note?.account.acct}'s avatar`" />
|
:alt="`${props.note?.account.acct}'s avatar'`" class="h-6 w-6 rounded ring-1 ring-white/10" />
|
||||||
</NuxtLink>
|
<span><strong v-html="eventualReblogAccountName"></strong> reblogged</span>
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
<div class="flex flex-col items-start justify-around ml-4 grow overflow-hidden">
|
|
||||||
<div class="flex flex-row items-center justify-between w-full">
|
|
||||||
<NuxtLink :href="accountUrl" class="font-semibold text-gray-200 line-clamp-1 break-all">
|
|
||||||
<Skeleton :enabled="isLoading" :min-width="90" :max-width="170" shape="rect">
|
|
||||||
{{
|
|
||||||
note?.account.display_name }}
|
|
||||||
</Skeleton>
|
|
||||||
</NuxtLink>
|
|
||||||
<NuxtLink :href="noteUrl" class="text-gray-400 text-sm ml-2 line-clamp-1 break-all shrink-0">
|
|
||||||
<Skeleton :enabled="isLoading" :min-width="50" :max-width="100" shape="rect">
|
|
||||||
{{ timeAgo }}
|
|
||||||
</Skeleton>
|
|
||||||
</NuxtLink>
|
|
||||||
</div>
|
</div>
|
||||||
<span class="text-gray-400 text-sm line-clamp-1 break-all w-full">
|
<SocialElementsNotesHeader :note="note" :small="small" />
|
||||||
<Skeleton :enabled="isLoading" :min-width="130" :max-width="250" shape="rect">
|
<div v-if="!noteClosed">
|
||||||
@{{
|
<NuxtLink :href="noteUrl" class="mt-6 block relative">
|
||||||
note?.account.acct
|
<Skeleton :enabled="true" v-if="!note" :min-width="50" :max-width="100" width-unit="%" shape="rect"
|
||||||
}}
|
|
||||||
</Skeleton>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<NuxtLink :href="noteUrl" class="mt-6">
|
|
||||||
<Skeleton :enabled="true" v-if="isLoading" :min-width="50" :max-width="100" width-unit="%" shape="rect"
|
|
||||||
type="content">
|
type="content">
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
<div v-else-if="content" class="prose prose-invert prose-a:no-underline content" v-html="content">
|
<div v-else-if="content"
|
||||||
|
:class="['prose prose-invert duration-200 !max-w-full break-words prose-a:no-underline content']"
|
||||||
|
v-html="content">
|
||||||
</div>
|
</div>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<div v-if="attachments.length > 0" class="[&:not(:first-child)]:mt-6">
|
<div v-if="attachments.length > 0" class="[&:not(:first-child)]:mt-6">
|
||||||
<SocialElementsNotesAttachment v-for="attachment of attachments" :key="attachment.id"
|
<SocialElementsNotesAttachment v-for="attachment of attachments" :key="attachment.id"
|
||||||
:attachment="attachment" />
|
:attachment="attachment" />
|
||||||
</div>
|
</div>
|
||||||
<Skeleton class="!h-10 w-full mt-6" :enabled="true" v-if="isLoading"></Skeleton>
|
</div>
|
||||||
<div v-else
|
<div v-else
|
||||||
|
class="rounded text-center ring-1 !max-w-full ring-white/10 h-52 mt-6 prose prose-invert p-4 flex flex-col justify-center items-center">
|
||||||
|
<strong v-if="note?.sensitive" class="max-w-64">This note was tagged as containing sensitive
|
||||||
|
content</strong>
|
||||||
|
<!-- Spoiler text is it's specified -->
|
||||||
|
<span v-if="note?.spoiler_text" class="mt-2 break-all">{{ note.spoiler_text
|
||||||
|
}}</span>
|
||||||
|
<ButtonsSecondary @click="noteClosed = false" class="mt-4">Show content</ButtonsSecondary>
|
||||||
|
</div>
|
||||||
|
<Skeleton class="!h-10 w-full mt-6" :enabled="true" v-if="!note && !small"></Skeleton>
|
||||||
|
<div v-else-if="!small"
|
||||||
class="mt-6 flex flex-row items-stretch relative justify-between text-sm h-10 hover:[&>button]:bg-dark-800 [&>button]:duration-200 [&>button]:rounded [&>button]:flex [&>button]:flex-1 [&>button]:flex-row [&>button]:items-center [&>button]:justify-center">
|
class="mt-6 flex flex-row items-stretch relative justify-between text-sm h-10 hover:[&>button]:bg-dark-800 [&>button]:duration-200 [&>button]:rounded [&>button]:flex [&>button]:flex-1 [&>button]:flex-row [&>button]:items-center [&>button]:justify-center">
|
||||||
<button>
|
<button>
|
||||||
<Icon name="tabler:arrow-back-up" class="h-5 w-5 text-gray-200" aria-hidden="true" />
|
<Icon name="tabler:arrow-back-up" class="h-5 w-5 text-gray-200" aria-hidden="true" />
|
||||||
|
|
@ -94,20 +86,22 @@ import type { Status } from "~/types/mastodon/status";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
note?: Status;
|
note?: Status;
|
||||||
skeleton?: boolean;
|
small?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const isLoading = props.skeleton;
|
// Handle reblogs
|
||||||
const timeAgo = useTimeAgo(props.note?.created_at ?? 0);
|
const note = computed(() => props.note?.reblog ?? props.note);
|
||||||
|
const noteClosed = ref(note.value?.sensitive || !!note.value?.spoiler_text || false);
|
||||||
|
|
||||||
const { copy } = useClipboard();
|
const { copy } = useClipboard();
|
||||||
const client = await useMegalodon();
|
const client = useMegalodon();
|
||||||
const mentions = await useResolveMentions(props.note?.mentions ?? [], client);
|
const mentions = await useResolveMentions(note.value?.mentions ?? [], client);
|
||||||
|
const eventualReblogAccountName = props.note?.reblog ? (useParsedContent(props.note?.account.display_name, props.note?.account.emojis, mentions.value)).value : null;
|
||||||
const content =
|
const content =
|
||||||
props.note && process.client
|
note.value && process.client
|
||||||
? await useParsedContent(
|
? useParsedContent(
|
||||||
props.note.content,
|
note.value.content,
|
||||||
props.note.emojis,
|
note.value.emojis,
|
||||||
mentions.value,
|
mentions.value,
|
||||||
)
|
)
|
||||||
: "";
|
: "";
|
||||||
|
|
@ -117,9 +111,8 @@ const numberFormat = (number = 0) =>
|
||||||
compactDisplay: "short",
|
compactDisplay: "short",
|
||||||
maximumFractionDigits: 1,
|
maximumFractionDigits: 1,
|
||||||
}).format(number);
|
}).format(number);
|
||||||
const attachments = props.note?.media_attachments ?? [];
|
const attachments = note.value?.media_attachments ?? [];
|
||||||
const noteUrl = props.note && `/@${props.note.account.acct}/${props.note.id}`;
|
const noteUrl = note.value && `/@${note.value.account.acct}/${note.value.id}`;
|
||||||
const accountUrl = props.note && `/@${props.note.account.acct}`;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
||||||
67
components/social-elements/notifications/notif.vue
Normal file
67
components/social-elements/notifications/notif.vue
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
<template>
|
||||||
|
<div class="flex flex-col p-1 bg-dark-400">
|
||||||
|
<div class="px-4 pt-2 pb-3 flex flex-row gap-2 items-center">
|
||||||
|
<Skeleton :enabled="!notification" shape="rect" class="!h-6" :min-width="40" :max-width="100"
|
||||||
|
width-unit="%">
|
||||||
|
<Icon :name="icon" class="h-6 w-6 text-gray-200" aria-hidden="true" />
|
||||||
|
<img v-if="notification?.account?.avatar" :src="notification?.account.avatar"
|
||||||
|
:alt="`${notification?.account.acct}'s avatar'`" class="h-6 w-6 rounded ring-1 ring-white/10" />
|
||||||
|
<span class="text-gray-200"><strong v-html="accountName"></strong> {{ text }}</span>
|
||||||
|
</Skeleton>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<SocialElementsNotesNote v-if="notification?.status || !notification" :note="notification?.status"
|
||||||
|
:small="true" />
|
||||||
|
<div v-else-if="notification.account" class="p-6 ring-1 ring-white/5 bg-dark-800">
|
||||||
|
<SocialElementsUsersSmallCard :account="notification.account" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { Notification } from '~/types/mastodon/notification';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
notification?: Notification;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const accountName = useParsedContent(props.notification?.account?.display_name ?? '', props.notification?.account?.emojis ?? [], []);
|
||||||
|
const text = computed(() => {
|
||||||
|
if (!props.notification) return '';
|
||||||
|
|
||||||
|
switch (props.notification.type) {
|
||||||
|
case 'mention':
|
||||||
|
return 'mentioned you';
|
||||||
|
case 'reblog':
|
||||||
|
return 'reblogged your note';
|
||||||
|
case 'favourite':
|
||||||
|
return 'liked your note';
|
||||||
|
case 'follow':
|
||||||
|
return 'followed you';
|
||||||
|
case 'follow_request':
|
||||||
|
return 'requested to follow you';
|
||||||
|
default:
|
||||||
|
console.error('Unknown notification type', props.notification.type)
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const icon = computed(() => {
|
||||||
|
if (!props.notification) return '';
|
||||||
|
|
||||||
|
switch (props.notification.type) {
|
||||||
|
case 'mention':
|
||||||
|
return 'tabler:at';
|
||||||
|
case 'reblog':
|
||||||
|
return 'tabler:repeat';
|
||||||
|
case 'favourite':
|
||||||
|
return 'tabler:heart';
|
||||||
|
case 'follow':
|
||||||
|
return 'tabler:plus';
|
||||||
|
case 'follow_request':
|
||||||
|
return 'tabler:plus';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -116,30 +116,28 @@ watch(
|
||||||
async () => {
|
async () => {
|
||||||
if (skeleton.value) return;
|
if (skeleton.value) return;
|
||||||
parsedNote.value = (
|
parsedNote.value = (
|
||||||
await useParsedContent(
|
useParsedContent(
|
||||||
props.account?.note ?? "",
|
props.account?.note ?? "",
|
||||||
props.account?.emojis ?? [],
|
props.account?.emojis ?? [],
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
).value;
|
).value ?? "";
|
||||||
parsedFields.value = await Promise.all(
|
parsedFields.value = props.account?.fields.map((field) => ({
|
||||||
props.account?.fields.map(async (field) => ({
|
name: (
|
||||||
name: await (
|
useParsedContent(
|
||||||
await useParsedContent(
|
|
||||||
field.name,
|
field.name,
|
||||||
props.account?.emojis ?? [],
|
props.account?.emojis ?? [],
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
).value,
|
).value ?? "",
|
||||||
value: await (
|
value: (
|
||||||
await useParsedContent(
|
useParsedContent(
|
||||||
field.value,
|
field.value,
|
||||||
props.account?.emojis ?? [],
|
props.account?.emojis ?? [],
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
).value,
|
).value ?? "",
|
||||||
})) ?? [],
|
})) ?? [];
|
||||||
);
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLink :href="accountUrl" class="flex flex-row">
|
<NuxtLink :href="accountUrl" class="flex flex-row">
|
||||||
<Skeleton :enabled="skeleton" shape="rect" class="!h-12 w-12">
|
<Skeleton :enabled="!account" shape="rect" class="!h-12 w-12">
|
||||||
<div>
|
<div>
|
||||||
<img class="h-12 w-12 rounded ring-1 ring-white/5" :src="account?.avatar"
|
<img class="h-12 w-12 rounded ring-1 ring-white/5" :src="account?.avatar"
|
||||||
:alt="`${account?.acct}'s avatar'`" />
|
:alt="`${account?.acct}'s avatar'`" />
|
||||||
|
|
@ -9,14 +9,14 @@
|
||||||
<div class="flex flex-col items-start justify-around ml-4 grow overflow-hidden">
|
<div class="flex flex-col items-start justify-around ml-4 grow overflow-hidden">
|
||||||
<div class="flex flex-row items-center justify-between w-full">
|
<div class="flex flex-row items-center justify-between w-full">
|
||||||
<div class="font-semibold text-gray-200 line-clamp-1 break-all">
|
<div class="font-semibold text-gray-200 line-clamp-1 break-all">
|
||||||
<Skeleton :enabled="skeleton" :min-width="90" :max-width="170" shape="rect">
|
<Skeleton :enabled="!account" :min-width="90" :max-width="170" shape="rect">
|
||||||
{{
|
{{
|
||||||
account?.display_name }}
|
account?.display_name }}
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-gray-400 text-sm line-clamp-1 break-all w-full">
|
<span class="text-gray-400 text-sm line-clamp-1 break-all w-full">
|
||||||
<Skeleton :enabled="skeleton" :min-width="130" :max-width="250" shape="rect">
|
<Skeleton :enabled="!account" :min-width="130" :max-width="250" shape="rect">
|
||||||
@{{
|
@{{
|
||||||
account?.acct
|
account?.acct
|
||||||
}}
|
}}
|
||||||
|
|
@ -29,15 +29,9 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Account } from "~/types/mastodon/account";
|
import type { Account } from "~/types/mastodon/account";
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = defineProps<{
|
||||||
defineProps<{
|
|
||||||
account?: Account;
|
account?: Account;
|
||||||
skeleton?: boolean;
|
}>();
|
||||||
}>(),
|
|
||||||
{
|
|
||||||
skeleton: false,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const accountUrl = props.account && `/@${props.account.acct}`;
|
const accountUrl = props.account && `/@${props.account.acct}`;
|
||||||
</script>
|
</script>
|
||||||
50
components/timelines/Notifications.vue
Normal file
50
components/timelines/Notifications.vue
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<template>
|
||||||
|
<ClientOnly>
|
||||||
|
|
||||||
|
<SocialElementsNotificationsNotif v-for="notif of timeline" :key="notif.id" :notification="notif" />
|
||||||
|
<span ref="skeleton"></span>
|
||||||
|
<SocialElementsNotificationsNotif v-for="index of 5" v-if="!hasReachedEnd" :skeleton="true" />
|
||||||
|
|
||||||
|
<div v-if="hasReachedEnd"
|
||||||
|
class="text-center flex flex-row justify-center items-center py-10 text-gray-400 gap-3">
|
||||||
|
<Icon name="tabler:message-off" class="h-6 w-6" />
|
||||||
|
<span>No more notifications, you've seen them all</span>
|
||||||
|
</div>
|
||||||
|
</ClientOnly>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
const access_token = useLocalStorage("lysand:access_token", null);
|
||||||
|
const client = useMegalodon(access_token);
|
||||||
|
|
||||||
|
const isLoading = ref(true);
|
||||||
|
|
||||||
|
const timelineParameters = ref({});
|
||||||
|
const hasReachedEnd = ref(false);
|
||||||
|
const { timeline, loadNext, loadPrev } = useNotificationTimeline(
|
||||||
|
client,
|
||||||
|
timelineParameters,
|
||||||
|
);
|
||||||
|
const skeleton = ref<HTMLSpanElement | null>(null);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
useIntersectionObserver(skeleton, async (entries) => {
|
||||||
|
if (
|
||||||
|
entries[0].isIntersecting &&
|
||||||
|
!hasReachedEnd.value &&
|
||||||
|
!isLoading.value
|
||||||
|
) {
|
||||||
|
isLoading.value = true;
|
||||||
|
await loadNext();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(timeline, (newTimeline, oldTimeline) => {
|
||||||
|
isLoading.value = false;
|
||||||
|
// If less than NOTES_PER_PAGE statuses are returned, we have reached the end
|
||||||
|
if (newTimeline.length - oldTimeline.length < useConfig().NOTES_PER_PAGE) {
|
||||||
|
hasReachedEnd.value = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
const client = await useMegalodon();
|
const client = useMegalodon();
|
||||||
|
|
||||||
const isLoading = ref(true);
|
const isLoading = ref(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
import type { Mastodon } from "megalodon";
|
import type { Mastodon } from "megalodon";
|
||||||
|
import type { Account } from "~/types/mastodon/account";
|
||||||
|
|
||||||
export const useAccount = async (
|
export const useAccount = (client: Mastodon | null, accountId: string) => {
|
||||||
client: Mastodon | null,
|
|
||||||
accountId: string,
|
|
||||||
) => {
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return null;
|
return ref(null as Account | null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await client.getAccount(accountId)).data;
|
const output = ref(null as Account | null);
|
||||||
|
|
||||||
|
client.getAccount(accountId).then((res) => {
|
||||||
|
output.value = res.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ import type { Status } from "~/types/mastodon/status";
|
||||||
export const useAccountTimeline = (
|
export const useAccountTimeline = (
|
||||||
client: Mastodon | null,
|
client: Mastodon | null,
|
||||||
id: MaybeRef<string | null>,
|
id: MaybeRef<string | null>,
|
||||||
options: MaybeRef<
|
options: MaybeRef<{
|
||||||
Partial<{
|
|
||||||
limit?: number | undefined;
|
limit?: number | undefined;
|
||||||
max_id?: string | undefined;
|
max_id?: string | undefined;
|
||||||
since_id?: string | undefined;
|
since_id?: string | undefined;
|
||||||
|
|
@ -13,15 +12,24 @@ export const useAccountTimeline = (
|
||||||
pinned?: boolean | undefined;
|
pinned?: boolean | undefined;
|
||||||
exclude_replies?: boolean | undefined;
|
exclude_replies?: boolean | undefined;
|
||||||
exclude_reblogs?: boolean | undefined;
|
exclude_reblogs?: boolean | undefined;
|
||||||
only_media: boolean;
|
only_media?: boolean;
|
||||||
}>
|
}>,
|
||||||
>,
|
|
||||||
): {
|
): {
|
||||||
timeline: Ref<Status[]>;
|
timeline: Ref<Status[]>;
|
||||||
loadNext: () => Promise<void>;
|
loadNext: () => Promise<void>;
|
||||||
loadPrev: () => Promise<void>;
|
loadPrev: () => Promise<void>;
|
||||||
} => {
|
} => {
|
||||||
if (!client) {
|
return useIdTimeline(
|
||||||
|
client,
|
||||||
|
id,
|
||||||
|
(client, options) =>
|
||||||
|
client?.getAccountStatuses(ref(id).value ?? "", {
|
||||||
|
only_media: false,
|
||||||
|
...options,
|
||||||
|
}),
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
/* if (!client) {
|
||||||
return {
|
return {
|
||||||
timeline: ref([]),
|
timeline: ref([]),
|
||||||
loadNext: async () => {},
|
loadNext: async () => {},
|
||||||
|
|
@ -88,5 +96,5 @@ export const useAccountTimeline = (
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
return { timeline: fetchedNotes, loadNext, loadPrev };
|
return { timeline: fetchedNotes, loadNext, loadPrev }; */
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,20 @@
|
||||||
import type { Mastodon } from "megalodon";
|
import type { Mastodon } from "megalodon";
|
||||||
|
|
||||||
export const useExtendedDescription = async (client: Mastodon | null) => {
|
type ExtendedDescription = {
|
||||||
if (!client) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (await client.client.get("/api/v1/instance/extended_description"))
|
|
||||||
.data as {
|
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
content: string;
|
content: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useExtendedDescription = (client: Mastodon | null) => {
|
||||||
|
if (!client) {
|
||||||
|
return ref(null as ExtendedDescription | null);
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = ref(null as ExtendedDescription | null);
|
||||||
|
|
||||||
|
client.client.get("/api/v1/instance/extended_description").then((res) => {
|
||||||
|
output.value = res.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,21 @@
|
||||||
import type { Mastodon } from "megalodon";
|
import type { Mastodon } from "megalodon";
|
||||||
import type { Instance } from "~/types/mastodon/instance";
|
import type { Instance } from "~/types/mastodon/instance";
|
||||||
|
|
||||||
export const useInstance = async (client: Mastodon | null) => {
|
type InstanceWithExtra = Instance & {
|
||||||
if (!client) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (await client.getInstance()).data as Instance & {
|
|
||||||
banner?: string;
|
banner?: string;
|
||||||
lysand_version?: string;
|
lysand_version?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useInstance = (client: Mastodon | null) => {
|
||||||
|
if (!client) {
|
||||||
|
return ref(null as InstanceWithExtra | null);
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = ref(null as InstanceWithExtra | null);
|
||||||
|
|
||||||
|
client.getInstance().then((res) => {
|
||||||
|
output.value = res.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
import { Mastodon } from "megalodon";
|
import { Mastodon } from "megalodon";
|
||||||
|
|
||||||
export const useMegalodon = async (disableOnServer = false) => {
|
export const useMegalodon = (
|
||||||
|
accessToken?: MaybeRef<string | null | undefined>,
|
||||||
|
disableOnServer = false,
|
||||||
|
) => {
|
||||||
if (disableOnServer && process.server) {
|
if (disableOnServer && process.server) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseUrl = useBaseUrl().value;
|
const baseUrl = useBaseUrl().value;
|
||||||
|
|
||||||
const client = new Mastodon(baseUrl);
|
const client = new Mastodon(baseUrl, ref(accessToken).value);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,16 @@
|
||||||
import type { Mastodon } from "megalodon";
|
import type { Mastodon } from "megalodon";
|
||||||
|
import type { Status } from "~/types/mastodon/status";
|
||||||
|
|
||||||
export const useNote = async (client: Mastodon | null, noteId: string) => {
|
export const useNote = (client: Mastodon | null, noteId: string) => {
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return null;
|
return ref(null as Status | null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await client.getStatus(noteId)).data;
|
const output = ref(null as Status | null);
|
||||||
|
|
||||||
|
client.getStatus(noteId).then((res) => {
|
||||||
|
output.value = res.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
24
composables/NotificationTimeline.ts
Normal file
24
composables/NotificationTimeline.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import type { Mastodon } from "megalodon";
|
||||||
|
import type { Notification } from "~/types/mastodon/notification";
|
||||||
|
|
||||||
|
export const useNotificationTimeline = (
|
||||||
|
client: Mastodon | null,
|
||||||
|
options: MaybeRef<{
|
||||||
|
limit?: number | undefined;
|
||||||
|
max_id?: string | undefined;
|
||||||
|
since_id?: string | undefined;
|
||||||
|
min_id?: string | undefined;
|
||||||
|
exclude_types?: string[] | undefined;
|
||||||
|
account_id?: string | undefined;
|
||||||
|
}>,
|
||||||
|
): {
|
||||||
|
timeline: Ref<Notification[]>;
|
||||||
|
loadNext: () => Promise<void>;
|
||||||
|
loadPrev: () => Promise<void>;
|
||||||
|
} => {
|
||||||
|
return useTimeline(
|
||||||
|
client,
|
||||||
|
(client, options) => client?.getNotifications(options),
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
@ -9,11 +9,14 @@ import MentionComponent from "../components/social-elements/notes/mention.vue";
|
||||||
* @param emojis Array of emojis to parse
|
* @param emojis Array of emojis to parse
|
||||||
* @returns Reactive object with the parsed content
|
* @returns Reactive object with the parsed content
|
||||||
*/
|
*/
|
||||||
export const useParsedContent = async (
|
export const useParsedContent = (
|
||||||
content: string,
|
content: string,
|
||||||
emojis: Emoji[],
|
emojis: Emoji[],
|
||||||
mentions: Account[],
|
mentions: Account[],
|
||||||
): Promise<Ref<string>> => {
|
): Ref<string | null> => {
|
||||||
|
const result = ref(null as string | null);
|
||||||
|
|
||||||
|
(async () => {
|
||||||
const contentHtml = document.createElement("div");
|
const contentHtml = document.createElement("div");
|
||||||
contentHtml.innerHTML = content;
|
contentHtml.innerHTML = content;
|
||||||
|
|
||||||
|
|
@ -43,7 +46,9 @@ export const useParsedContent = async (
|
||||||
const links = contentHtml.querySelectorAll("a");
|
const links = contentHtml.querySelectorAll("a");
|
||||||
|
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
const mention = mentions.find((m) => link.textContent === `@${m.acct}`);
|
const mention = mentions.find(
|
||||||
|
(m) => link.textContent === `@${m.acct}`,
|
||||||
|
);
|
||||||
if (!mention) {
|
if (!mention) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -74,5 +79,9 @@ export const useParsedContent = async (
|
||||||
}
|
}
|
||||||
parent.outerHTML = newCode;
|
parent.outerHTML = newCode;
|
||||||
}
|
}
|
||||||
return ref(contentHtml.innerHTML);
|
|
||||||
|
result.value = contentHtml.innerHTML;
|
||||||
|
})();
|
||||||
|
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,84 +3,21 @@ import type { Status } from "~/types/mastodon/status";
|
||||||
|
|
||||||
export const usePublicTimeline = (
|
export const usePublicTimeline = (
|
||||||
client: Mastodon | null,
|
client: Mastodon | null,
|
||||||
options: MaybeRef<
|
options: MaybeRef<{
|
||||||
Partial<{
|
only_media?: boolean;
|
||||||
only_media: boolean;
|
limit?: number;
|
||||||
max_id: string;
|
max_id?: string;
|
||||||
since_id: string;
|
since_id?: string;
|
||||||
min_id: string;
|
min_id?: string;
|
||||||
limit: number;
|
}>,
|
||||||
}>
|
|
||||||
>,
|
|
||||||
): {
|
): {
|
||||||
timeline: Ref<Status[]>;
|
timeline: Ref<Status[]>;
|
||||||
loadNext: () => Promise<void>;
|
loadNext: () => Promise<void>;
|
||||||
loadPrev: () => Promise<void>;
|
loadPrev: () => Promise<void>;
|
||||||
} => {
|
} => {
|
||||||
if (!client) {
|
return useTimeline(
|
||||||
return {
|
client,
|
||||||
timeline: ref([]),
|
(client, options) => client?.getPublicTimeline(options),
|
||||||
loadNext: async () => {},
|
options,
|
||||||
loadPrev: async () => {},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchedNotes = ref<Status[]>([]);
|
|
||||||
const fetchedNoteIds = new Set<string>();
|
|
||||||
let nextMaxId: string | undefined = undefined;
|
|
||||||
let prevMinId: string | undefined = undefined;
|
|
||||||
|
|
||||||
const loadNext = async () => {
|
|
||||||
const response = await client.getPublicTimeline({
|
|
||||||
...ref(options).value,
|
|
||||||
max_id: nextMaxId,
|
|
||||||
limit: useConfig().NOTES_PER_PAGE,
|
|
||||||
});
|
|
||||||
|
|
||||||
const newNotes = response.data.filter(
|
|
||||||
(note) => !fetchedNoteIds.has(note.id),
|
|
||||||
);
|
);
|
||||||
if (newNotes.length > 0) {
|
|
||||||
fetchedNotes.value = [...fetchedNotes.value, ...newNotes];
|
|
||||||
nextMaxId = newNotes[newNotes.length - 1].id;
|
|
||||||
for (const note of newNotes) {
|
|
||||||
fetchedNoteIds.add(note.id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
nextMaxId = undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadPrev = async () => {
|
|
||||||
const response = await client.getPublicTimeline({
|
|
||||||
...ref(options).value,
|
|
||||||
min_id: prevMinId,
|
|
||||||
limit: useConfig().NOTES_PER_PAGE,
|
|
||||||
});
|
|
||||||
|
|
||||||
const newNotes = response.data.filter(
|
|
||||||
(note) => !fetchedNoteIds.has(note.id),
|
|
||||||
);
|
|
||||||
if (newNotes.length > 0) {
|
|
||||||
fetchedNotes.value = [...newNotes, ...fetchedNotes.value];
|
|
||||||
prevMinId = newNotes[0].id;
|
|
||||||
for (const note of newNotes) {
|
|
||||||
fetchedNoteIds.add(note.id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prevMinId = undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => ref(options).value,
|
|
||||||
async ({ max_id, min_id }) => {
|
|
||||||
nextMaxId = max_id;
|
|
||||||
prevMinId = min_id;
|
|
||||||
await loadNext();
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
return { timeline: fetchedNotes, loadNext, loadPrev };
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
176
composables/Timeline.ts
Normal file
176
composables/Timeline.ts
Normal file
|
|
@ -0,0 +1,176 @@
|
||||||
|
import type { Mastodon, Response } from "megalodon";
|
||||||
|
|
||||||
|
interface BaseOptions {
|
||||||
|
max_id?: string;
|
||||||
|
min_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type FetchTimelineFunction<Element, Options> = (
|
||||||
|
client: Mastodon,
|
||||||
|
options: Options & BaseOptions,
|
||||||
|
) => Promise<Response<Element[]>>;
|
||||||
|
|
||||||
|
export const useTimeline = <
|
||||||
|
Element extends {
|
||||||
|
id: string;
|
||||||
|
},
|
||||||
|
Options,
|
||||||
|
>(
|
||||||
|
client: Mastodon | null,
|
||||||
|
fetchTimeline: FetchTimelineFunction<Element, Options> | null | undefined,
|
||||||
|
options: MaybeRef<Options & BaseOptions>,
|
||||||
|
): {
|
||||||
|
timeline: Ref<Element[]>;
|
||||||
|
loadNext: () => Promise<void>;
|
||||||
|
loadPrev: () => Promise<void>;
|
||||||
|
} => {
|
||||||
|
if (!client || !fetchTimeline) {
|
||||||
|
return {
|
||||||
|
timeline: ref([]),
|
||||||
|
loadNext: async () => {},
|
||||||
|
loadPrev: async () => {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchedNotes: Ref<Element[]> = ref([]);
|
||||||
|
const fetchedNoteIds = new Set<string>();
|
||||||
|
let nextMaxId: string | undefined = undefined;
|
||||||
|
let prevMinId: string | undefined = undefined;
|
||||||
|
|
||||||
|
const loadNext = async () => {
|
||||||
|
const response = await fetchTimeline(client, {
|
||||||
|
...(ref(options).value as Options & BaseOptions),
|
||||||
|
max_id: nextMaxId,
|
||||||
|
limit: useConfig().NOTES_PER_PAGE,
|
||||||
|
});
|
||||||
|
|
||||||
|
const newNotes = response.data.filter(
|
||||||
|
(note) => !fetchedNoteIds.has(note.id),
|
||||||
|
);
|
||||||
|
if (newNotes.length > 0) {
|
||||||
|
fetchedNotes.value = [...fetchedNotes.value, ...newNotes];
|
||||||
|
nextMaxId = newNotes[newNotes.length - 1].id;
|
||||||
|
for (const note of newNotes) {
|
||||||
|
fetchedNoteIds.add(note.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nextMaxId = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadPrev = async () => {
|
||||||
|
const response = await fetchTimeline(client, {
|
||||||
|
...(ref(options).value as Options & BaseOptions),
|
||||||
|
min_id: prevMinId,
|
||||||
|
limit: useConfig().NOTES_PER_PAGE,
|
||||||
|
});
|
||||||
|
|
||||||
|
const newNotes = response.data.filter(
|
||||||
|
(note) => !fetchedNoteIds.has(note.id),
|
||||||
|
);
|
||||||
|
if (newNotes.length > 0) {
|
||||||
|
fetchedNotes.value = [...newNotes, ...fetchedNotes.value];
|
||||||
|
prevMinId = newNotes[0].id;
|
||||||
|
for (const note of newNotes) {
|
||||||
|
fetchedNoteIds.add(note.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prevMinId = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => ref(options).value,
|
||||||
|
async ({ max_id, min_id }) => {
|
||||||
|
nextMaxId = max_id;
|
||||||
|
prevMinId = min_id;
|
||||||
|
await loadNext();
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
return { timeline: fetchedNotes, loadNext, loadPrev };
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useIdTimeline = <
|
||||||
|
Element extends {
|
||||||
|
id: string;
|
||||||
|
},
|
||||||
|
Options,
|
||||||
|
>(
|
||||||
|
client: Mastodon | null,
|
||||||
|
id: MaybeRef<string | null>,
|
||||||
|
fetchTimeline: FetchTimelineFunction<Element, Options> | null | undefined,
|
||||||
|
options: MaybeRef<Options & BaseOptions>,
|
||||||
|
): {
|
||||||
|
timeline: Ref<Element[]>;
|
||||||
|
loadNext: () => Promise<void>;
|
||||||
|
loadPrev: () => Promise<void>;
|
||||||
|
} => {
|
||||||
|
if (!client || !fetchTimeline) {
|
||||||
|
return {
|
||||||
|
timeline: ref([]),
|
||||||
|
loadNext: async () => {},
|
||||||
|
loadPrev: async () => {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchedNotes: Ref<Element[]> = ref([]);
|
||||||
|
const fetchedNoteIds = new Set<string>();
|
||||||
|
let nextMaxId: string | undefined = undefined;
|
||||||
|
let prevMinId: string | undefined = undefined;
|
||||||
|
|
||||||
|
const loadNext = async () => {
|
||||||
|
const response = await fetchTimeline(client, {
|
||||||
|
...(ref(options).value as Options & BaseOptions),
|
||||||
|
max_id: nextMaxId,
|
||||||
|
limit: useConfig().NOTES_PER_PAGE,
|
||||||
|
});
|
||||||
|
|
||||||
|
const newNotes = response.data.filter(
|
||||||
|
(note) => !fetchedNoteIds.has(note.id),
|
||||||
|
);
|
||||||
|
if (newNotes.length > 0) {
|
||||||
|
fetchedNotes.value = [...fetchedNotes.value, ...newNotes];
|
||||||
|
nextMaxId = newNotes[newNotes.length - 1].id;
|
||||||
|
for (const note of newNotes) {
|
||||||
|
fetchedNoteIds.add(note.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nextMaxId = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadPrev = async () => {
|
||||||
|
const response = await fetchTimeline(client, {
|
||||||
|
...(ref(options).value as Options & BaseOptions),
|
||||||
|
min_id: prevMinId,
|
||||||
|
limit: useConfig().NOTES_PER_PAGE,
|
||||||
|
});
|
||||||
|
|
||||||
|
const newNotes = response.data.filter(
|
||||||
|
(note) => !fetchedNoteIds.has(note.id),
|
||||||
|
);
|
||||||
|
if (newNotes.length > 0) {
|
||||||
|
fetchedNotes.value = [...newNotes, ...fetchedNotes.value];
|
||||||
|
prevMinId = newNotes[0].id;
|
||||||
|
for (const note of newNotes) {
|
||||||
|
fetchedNoteIds.add(note.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prevMinId = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[() => ref(id).value, () => ref(options).value],
|
||||||
|
async ([id, { max_id, min_id }]) => {
|
||||||
|
nextMaxId = max_id;
|
||||||
|
prevMinId = min_id;
|
||||||
|
id && (await loadNext());
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
return { timeline: fetchedNotes, loadNext, loadPrev };
|
||||||
|
};
|
||||||
|
|
@ -3,18 +3,24 @@
|
||||||
<SidebarsNavigation />
|
<SidebarsNavigation />
|
||||||
<div class="relative md:pl-20 min-h-dvh flex flex-row justify-center lg:justify-between">
|
<div class="relative md:pl-20 min-h-dvh flex flex-row justify-center lg:justify-between">
|
||||||
<aside
|
<aside
|
||||||
class="max-w-md max-h-dvh overflow-y-auto w-full bg-dark-900 ring-1 ring-white/10 hidden lg:flex p-10 flex-col gap-10">
|
class="max-w-md max-h-dvh overflow-y-auto w-full bg-dark-900 ring-1 ring-white/10 hidden lg:flex flex-col gap-10">
|
||||||
<div class="grow">
|
<ClientOnly>
|
||||||
|
<div class="grow p-10" v-if="!accessToken">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="relative block w-full h-full rounded-lg border-2 border-dashed border-dark-300 p-12 text-center">
|
class="relative block h-full w-full rounded-lg border-2 border-dashed border-dark-300 p-12 text-center">
|
||||||
<Icon name="tabler:notification" class="mx-auto h-12 w-12 text-gray-400" />
|
<Icon name="tabler:notification" class="mx-auto h-12 w-12 text-gray-400" />
|
||||||
<span class="mt-3 block text-sm font-semibold text-gray-200 max-w-56 mx-auto">Notifications will
|
<span class="mt-3 block text-sm font-semibold text-gray-200 max-w-56 mx-auto">Notifications
|
||||||
|
will
|
||||||
appear here
|
appear here
|
||||||
when you
|
when you
|
||||||
sign in</span>
|
sign in</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-auto prose prose-invert prose-sm flex flex-col gap-4">
|
<div class="grow" v-else>
|
||||||
|
<TimelinesNotifications />
|
||||||
|
</div>
|
||||||
|
</ClientOnly>
|
||||||
|
<div class="mt-auto prose prose-invert prose-sm flex flex-col gap-4 px-10 pb-10">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<strong
|
<strong
|
||||||
class="bg-gradient-to-tr from-pink-300 via-purple-300 to-indigo-400 text-transparent bg-clip-text">Lysand
|
class="bg-gradient-to-tr from-pink-300 via-purple-300 to-indigo-400 text-transparent bg-clip-text">Lysand
|
||||||
|
|
@ -52,14 +58,15 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { convert } from "html-to-text";
|
import { convert } from "html-to-text";
|
||||||
|
|
||||||
const client = await useMegalodon();
|
const accessToken = useLocalStorage("lysand:access_token", "");
|
||||||
const instance = await useInstance(client);
|
const client = useMegalodon(accessToken);
|
||||||
const description = await useExtendedDescription(client);
|
const instance = useInstance(client);
|
||||||
|
const description = useExtendedDescription(client);
|
||||||
|
|
||||||
useServerSeoMeta({
|
useServerSeoMeta({
|
||||||
title: instance?.title,
|
title: instance.value?.title,
|
||||||
ogImage: instance?.banner,
|
ogImage: instance.value?.banner,
|
||||||
description: convert(description?.content ?? ""),
|
description: convert(description.value?.content ?? ""),
|
||||||
ogSiteName: "Lysand",
|
ogSiteName: "Lysand",
|
||||||
colorScheme: "dark",
|
colorScheme: "dark",
|
||||||
referrer: "no-referrer",
|
referrer: "no-referrer",
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const client = await useMegalodon();
|
const client = useMegalodon();
|
||||||
const uuid = route.params.uuid as string;
|
const uuid = route.params.uuid as string;
|
||||||
|
|
||||||
const note = await useNote(client, uuid);
|
const note = useNote(client, uuid);
|
||||||
|
|
||||||
useServerSeoMeta({
|
useServerSeoMeta({
|
||||||
title: note?.account.display_name,
|
title: note.value?.account.display_name,
|
||||||
description: note?.content,
|
description: note.value?.content,
|
||||||
ogImage: note?.media_attachments[0]?.preview_url,
|
ogImage: note.value?.media_attachments[0]?.preview_url,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -35,7 +35,7 @@ const { width } = useWindowSize();
|
||||||
const isMobile = computed(() => width.value < 1024);
|
const isMobile = computed(() => width.value < 1024);
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const client = await useMegalodon(true);
|
const client = useMegalodon(undefined, true);
|
||||||
const username = (route.params.username as string).replace("@", "");
|
const username = (route.params.username as string).replace("@", "");
|
||||||
|
|
||||||
const account: Ref<Account | null> = ref(null);
|
const account: Ref<Account | null> = ref(null);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "app",
|
layout: "app",
|
||||||
});
|
});
|
||||||
const client = await useMegalodon();
|
const client = useMegalodon();
|
||||||
|
|
||||||
const isLoading = ref(true);
|
const isLoading = ref(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex min-h-screen flex-col justify-center px-6 py-12 lg:px-8 relative">
|
<div class="flex min-h-screen flex-col justify-center px-6 py-12 gap-10 lg:px-8 relative">
|
||||||
<img src="https://camo.githubusercontent.com/353460d1fdb1667ec993159270dcece12c491fb38165460215a519ab93f4e554/68747470733a2f2f63646e2d7765622e63706c757370617463682e636f6d2f6c7973616e642e77656270"
|
<img src="https://camo.githubusercontent.com/353460d1fdb1667ec993159270dcece12c491fb38165460215a519ab93f4e554/68747470733a2f2f63646e2d7765622e63706c757370617463682e636f6d2f6c7973616e642e77656270"
|
||||||
alt="Lysand logo" class="mx-auto h-24 hidden md:block" />
|
alt="Lysand logo" class="mx-auto h-24 hidden md:block" />
|
||||||
<div v-if="instance && instance.registrations" class="mt-10 mx-auto w-full max-w-md">
|
<div v-if="instance && instance.registrations" class="mx-auto w-full max-w-md">
|
||||||
<div v-if="Object.keys(errors).length > 0"
|
<div v-if="Object.keys(errors).length > 0"
|
||||||
class="ring-1 ring-white/10 rounded p-4 bg-red-500 text-white mb-10">
|
class="ring-1 ring-white/10 rounded p-4 bg-red-500 text-white mb-10">
|
||||||
<h2 class="font-bold text-lg">Error</h2>
|
<h2 class="font-bold text-lg">Error</h2>
|
||||||
|
|
@ -114,8 +114,8 @@ const schema = toTypedSchema(
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const client = await useMegalodon();
|
const client = useMegalodon();
|
||||||
const instance = await useInstance(client);
|
const instance = useInstance(client);
|
||||||
|
|
||||||
const errors = ref<{
|
const errors = ref<{
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue