mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
feat: ✨ Add reply header rendering in notes
This commit is contained in:
parent
e90ff9d508
commit
dd62647928
|
|
@ -37,8 +37,7 @@ useListen("note:quote", async (note) => {
|
||||||
useEvent("composer:quote", note);
|
useEvent("composer:quote", note);
|
||||||
});
|
});
|
||||||
useListen("composer:open", () => {
|
useListen("composer:open", () => {
|
||||||
if (tokenData.value)
|
if (tokenData.value) open.value = true;
|
||||||
open.value = true;
|
|
||||||
});
|
});
|
||||||
useListen("composer:close", () => {
|
useListen("composer:close", () => {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Status } from '~/types/mastodon/status';
|
import type { Status } from "~/types/mastodon/status";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
content: string | null;
|
content: string | null;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
<span><strong v-html="reblogDisplayName"></strong> reblogged</span>
|
<span><strong v-html="reblogDisplayName"></strong> reblogged</span>
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
</div>
|
</div>
|
||||||
|
<SocialElementsNotesReplyHeader v-if="isReply" :account_id="note?.in_reply_to_account_id ?? null" />
|
||||||
<SocialElementsNotesHeader :note="note" :small="small" />
|
<SocialElementsNotesHeader :note="note" :small="small" />
|
||||||
<SocialElementsNotesNoteContent :note="note" :loaded="loaded" :url="url" :content="content" :is-quote="isQuote"
|
<SocialElementsNotesNoteContent :note="note" :loaded="loaded" :url="url" :content="content" :is-quote="isQuote"
|
||||||
:should-hide="shouldHide" />
|
:should-hide="shouldHide" />
|
||||||
|
|
@ -104,6 +105,7 @@ const {
|
||||||
url,
|
url,
|
||||||
isQuote,
|
isQuote,
|
||||||
reblog,
|
reblog,
|
||||||
|
isReply,
|
||||||
reblogDisplayName,
|
reblogDisplayName,
|
||||||
} = useNoteData(ref(props.note), client);
|
} = useNoteData(ref(props.note), client);
|
||||||
|
|
||||||
|
|
|
||||||
24
components/social-elements/notes/reply-header.vue
Normal file
24
components/social-elements/notes/reply-header.vue
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<template>
|
||||||
|
<NuxtLink :href="`/@${account?.acct}`"
|
||||||
|
class="mb-4 flex flex-row gap-2 items-center text-gray-300 opacity-70 line-clamp-1">
|
||||||
|
<Skeleton :enabled="!account" shape="rect" class="!h-6" :min-width="40" :max-width="100" width-unit="%">
|
||||||
|
<Icon name="tabler:arrow-back-up" class="size-6" aria-hidden="true" />
|
||||||
|
<span class="flex flex-row items-center gap-2 overflow-hidden flex-wrap break-all">
|
||||||
|
Replying to
|
||||||
|
<AvatarsCentered v-if="account?.avatar" :url="account?.avatar" :alt="`${account?.acct}'s avatar'`"
|
||||||
|
class="size-5 rounded inline-flex shrink-0 ring-1 ring-white/10" />
|
||||||
|
<strong class="line-clamp-1">{{ account?.display_name || account?.acct }}</strong>
|
||||||
|
</span>
|
||||||
|
</Skeleton>
|
||||||
|
</NuxtLink>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
const props = defineProps<{
|
||||||
|
account_id: string | null;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const tokenData = useTokenData();
|
||||||
|
const client = useMegalodon(tokenData);
|
||||||
|
const account = useAccount(client, props.account_id);
|
||||||
|
</script>
|
||||||
|
|
@ -3,7 +3,7 @@ import type { Account } from "~/types/mastodon/account";
|
||||||
|
|
||||||
export const useAccount = (
|
export const useAccount = (
|
||||||
client: MaybeRef<Mastodon | null>,
|
client: MaybeRef<Mastodon | null>,
|
||||||
accountId: string,
|
accountId: MaybeRef<string | null>,
|
||||||
) => {
|
) => {
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return ref(null as Account | null);
|
return ref(null as Account | null);
|
||||||
|
|
@ -11,11 +11,14 @@ export const useAccount = (
|
||||||
|
|
||||||
const output = ref(null as Account | null);
|
const output = ref(null as Account | null);
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
if (toValue(accountId))
|
||||||
ref(client)
|
ref(client)
|
||||||
.value?.getAccount(accountId)
|
.value?.getAccount(toValue(accountId) ?? "")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
output.value = res.data;
|
output.value = res.data;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ export const useNoteData = (
|
||||||
noteProp: MaybeRef<Status | undefined>,
|
noteProp: MaybeRef<Status | undefined>,
|
||||||
client: Ref<Mastodon | null>,
|
client: Ref<Mastodon | null>,
|
||||||
) => {
|
) => {
|
||||||
|
const isReply = computed(() => !!toValue(noteProp)?.in_reply_to_id);
|
||||||
const isQuote = computed(() => !!toValue(noteProp)?.quote);
|
const isQuote = computed(() => !!toValue(noteProp)?.quote);
|
||||||
const isReblog = computed(
|
const isReblog = computed(
|
||||||
() => !isQuote.value && !!toValue(noteProp)?.reblog,
|
() => !isQuote.value && !!toValue(noteProp)?.reblog,
|
||||||
|
|
@ -54,7 +55,7 @@ export const useNoteData = (
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result?.data) {
|
if (result?.data) {
|
||||||
useEvent("note:delete", result.data);
|
useEvent("note:delete", result.data as Status);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -66,6 +67,7 @@ export const useNoteData = (
|
||||||
reblog,
|
reblog,
|
||||||
reblogDisplayName,
|
reblogDisplayName,
|
||||||
shouldHide,
|
shouldHide,
|
||||||
|
isReply,
|
||||||
url,
|
url,
|
||||||
remove,
|
remove,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue