2024-04-22 09:38:51 +02:00
|
|
|
<template>
|
2024-06-10 06:33:14 +02:00
|
|
|
<article
|
2024-04-28 08:35:26 +02:00
|
|
|
class="first:rounded-t last:rounded-b ring-1 relative ring-white/5 p-6 flex flex-col bg-dark-800 hover:bg-dark-700 duration-200">
|
|
|
|
|
<!-- Overlay that blocks clicks for disabled notes -->
|
|
|
|
|
<div v-if="disabled" class="absolute z-10 inset-0 hover:cursor-not-allowed">
|
|
|
|
|
</div>
|
2024-06-16 03:42:48 +02:00
|
|
|
<div v-if="reblog" class="mb-4 flex flex-row gap-2 items-center text-primary-400">
|
2024-04-28 07:02:27 +02:00
|
|
|
<Skeleton :enabled="!loaded" shape="rect" class="!h-6" :min-width="40" :max-width="100" width-unit="%">
|
2024-05-12 11:04:00 +02:00
|
|
|
<iconify-icon width="1.5rem" height="1.5rem" icon="tabler:repeat" class="size-6" aria-hidden="true" />
|
2024-06-21 04:09:09 +02:00
|
|
|
<Avatar v-if="reblog.avatar" :src="reblog.avatar" :alt="`${reblog.acct}'s avatar'`"
|
2024-05-12 10:37:57 +02:00
|
|
|
class="size-6 rounded shrink-0 ring-1 ring-white/10" />
|
2024-04-28 07:02:27 +02:00
|
|
|
<span><strong v-html="reblogDisplayName"></strong> reblogged</span>
|
2024-04-22 09:38:51 +02:00
|
|
|
</Skeleton>
|
|
|
|
|
</div>
|
2024-06-21 04:09:09 +02:00
|
|
|
<ReplyHeader v-if="isReply" :account_id="outputtedNote?.in_reply_to_account_id ?? null" />
|
|
|
|
|
<Header :note="outputtedNote" :small="small" />
|
|
|
|
|
<NoteContent :note="outputtedNote" :loaded="loaded" :url="url" :content="content" :is-quote="isQuote"
|
|
|
|
|
:should-hide="shouldHide" />
|
2024-04-28 08:35:26 +02:00
|
|
|
<Skeleton class="!h-10 w-full mt-6" :enabled="!props.note || !loaded" v-if="!small || !showInteractions">
|
|
|
|
|
<div v-if="showInteractions"
|
2024-05-12 04:15:42 +02:00
|
|
|
class="mt-6 flex flex-row items-stretch disabled:*:opacity-70 [&>button]:max-w-28 disabled:*:cursor-not-allowed relative justify-around text-sm h-10 hover:enabled:[&>button]:bg-dark-800 [&>button]:duration-200 [&>button]:rounded [&>button]:flex [&>button]:flex-1 [&>button]:flex-row [&>button]:items-center [&>button]:justify-center">
|
2024-06-06 08:42:44 +02:00
|
|
|
<button class="group" @click="outputtedNote && useEvent('note:reply', outputtedNote)"
|
2024-06-10 05:24:55 +02:00
|
|
|
:disabled="!identity">
|
2024-05-12 11:04:00 +02:00
|
|
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:arrow-back-up"
|
|
|
|
|
class="text-gray-200 group-hover:group-enabled:text-blue-600" aria-hidden="true" />
|
2024-06-06 08:42:44 +02:00
|
|
|
<span class="text-gray-400 mt-0.5 ml-2">{{ numberFormat(outputtedNote?.replies_count) }}</span>
|
2024-04-28 08:35:26 +02:00
|
|
|
</button>
|
2024-06-10 05:24:55 +02:00
|
|
|
<button class="group" @click="likeFn" :disabled="!identity">
|
2024-06-06 08:42:44 +02:00
|
|
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:heart" v-if="!outputtedNote?.favourited"
|
2024-06-16 03:42:48 +02:00
|
|
|
class="size-5 text-gray-200 group-hover:group-enabled:text-primary-600" aria-hidden="true" />
|
2024-05-12 11:04:00 +02:00
|
|
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:heart-filled" v-else
|
2024-06-16 03:42:48 +02:00
|
|
|
class="size-5 text-primary-600 group-hover:group-enabled:text-gray-200" aria-hidden="true" />
|
2024-06-06 08:42:44 +02:00
|
|
|
<span class="text-gray-400 mt-0.5 ml-2">{{ numberFormat(outputtedNote?.favourites_count) }}</span>
|
2024-04-28 08:35:26 +02:00
|
|
|
</button>
|
2024-06-10 05:24:55 +02:00
|
|
|
<button class="group" @click="reblogFn" :disabled="!identity">
|
2024-06-06 08:42:44 +02:00
|
|
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:repeat" v-if="!outputtedNote?.reblogged"
|
2024-05-12 11:04:00 +02:00
|
|
|
class="size-5 text-gray-200 group-hover:group-enabled:text-green-600" aria-hidden="true" />
|
2024-06-05 02:03:15 +02:00
|
|
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:repeat" v-else
|
2024-05-12 11:04:00 +02:00
|
|
|
class="size-5 text-green-600 group-hover:group-enabled:text-gray-200" aria-hidden="true" />
|
2024-06-06 08:42:44 +02:00
|
|
|
<span class="text-gray-400 mt-0.5 ml-2">{{ numberFormat(outputtedNote?.reblogs_count) }}</span>
|
2024-04-28 08:35:26 +02:00
|
|
|
</button>
|
2024-06-06 08:42:44 +02:00
|
|
|
<button class="group" @click="outputtedNote && useEvent('note:quote', outputtedNote)"
|
2024-06-10 05:24:55 +02:00
|
|
|
:disabled="!identity">
|
2024-05-12 11:04:00 +02:00
|
|
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:quote"
|
|
|
|
|
class="size-5 text-gray-200 group-hover:group-enabled:text-blue-600" aria-hidden="true" />
|
2024-04-28 08:35:26 +02:00
|
|
|
<span class="text-gray-400 mt-0.5 ml-2">{{ numberFormat(0) }}</span>
|
|
|
|
|
</button>
|
2024-06-21 04:09:09 +02:00
|
|
|
<AdaptiveDropdown>
|
2024-04-28 08:35:26 +02:00
|
|
|
<template #button>
|
2024-06-05 02:03:15 +02:00
|
|
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:dots" class="size-5 text-gray-200"
|
|
|
|
|
aria-hidden="true" />
|
|
|
|
|
<span class="sr-only">Open menu</span>
|
2024-04-28 08:35:26 +02:00
|
|
|
</template>
|
2024-04-25 08:56:01 +02:00
|
|
|
|
2024-04-28 08:35:26 +02:00
|
|
|
<template #items>
|
2024-06-10 05:24:55 +02:00
|
|
|
<Menu.ItemGroup>
|
|
|
|
|
<Menu.Item value="" v-if="isMyAccount">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="outputtedNote && useEvent('note:edit', outputtedNote)"
|
2024-06-10 05:24:55 +02:00
|
|
|
icon="tabler:pencil" class="w-full">
|
|
|
|
|
Edit
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item value="">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="copy(JSON.stringify(props.note, null, 4))" icon="tabler:code"
|
|
|
|
|
class="w-full">
|
2024-06-10 05:24:55 +02:00
|
|
|
Copy API
|
|
|
|
|
Response
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item value="">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="copy(url)" icon="tabler:link" class="w-full">
|
2024-06-10 05:24:55 +02:00
|
|
|
Copy Link
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item value="" v-if="outputtedNote?.url && isRemote">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="copy(outputtedNote.url)" icon="tabler:link" class="w-full">
|
2024-06-10 05:24:55 +02:00
|
|
|
Copy Link (Origin)
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item value="" v-if="outputtedNote?.url && isRemote">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="openBlank(outputtedNote.url)" icon="tabler:external-link"
|
|
|
|
|
class="w-full">
|
2024-06-10 05:24:55 +02:00
|
|
|
View on Remote
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item value="" v-if="isMyAccount">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="remove" icon="tabler:backspace" :disabled="!identity"
|
2024-06-10 05:24:55 +02:00
|
|
|
class="w-full border-r-2 border-red-500">
|
|
|
|
|
Delete
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
</Menu.ItemGroup>
|
2024-06-12 05:53:55 +02:00
|
|
|
<hr class="border-white/10 rounded" v-if="identity" />
|
|
|
|
|
<Menu.ItemGroup v-if="identity">
|
2024-06-10 05:24:55 +02:00
|
|
|
<Menu.Item value="">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="outputtedNote && useEvent('note:reply', outputtedNote)"
|
2024-06-10 05:24:55 +02:00
|
|
|
icon="tabler:arrow-back-up" class="w-full">
|
|
|
|
|
Reply
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item value="">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="likeFn" icon="tabler:heart" class="w-full"
|
2024-06-10 05:24:55 +02:00
|
|
|
v-if="!outputtedNote?.favourited">
|
|
|
|
|
Like
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
|
|
|
|
<ButtonDropdown @click="likeFn" icon="tabler:heart-filled" class="w-full" v-else>
|
2024-06-10 05:24:55 +02:00
|
|
|
Unlike
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item value="">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="reblogFn" icon="tabler:repeat" class="w-full"
|
2024-06-10 05:24:55 +02:00
|
|
|
v-if="!outputtedNote?.reblogged">
|
|
|
|
|
Reblog
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
|
|
|
|
<ButtonDropdown @click="reblogFn" icon="tabler:repeat" class="w-full" v-else>
|
2024-06-10 05:24:55 +02:00
|
|
|
Unreblog
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item value="">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="outputtedNote && useEvent('note:quote', outputtedNote)"
|
2024-06-10 05:24:55 +02:00
|
|
|
icon="tabler:quote" class="w-full">
|
|
|
|
|
Quote
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
</Menu.ItemGroup>
|
2024-06-12 05:53:55 +02:00
|
|
|
<hr class="border-white/10 rounded" v-if="identity" />
|
|
|
|
|
<Menu.ItemGroup v-if="identity">
|
2024-06-10 05:24:55 +02:00
|
|
|
<Menu.Item value="">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown @click="outputtedNote && useEvent('note:report', outputtedNote)"
|
2024-06-10 05:24:55 +02:00
|
|
|
icon="tabler:flag" class="w-full"
|
2024-06-20 01:57:38 +02:00
|
|
|
:disabled="!permissions.includes(RolePermission.ManageOwnReports)">
|
2024-06-10 05:24:55 +02:00
|
|
|
Report
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
2024-06-20 01:57:38 +02:00
|
|
|
<Menu.Item value="" v-if="permissions.includes(RolePermission.ManageAccounts)">
|
2024-06-21 04:09:09 +02:00
|
|
|
<ButtonDropdown icon="tabler:shield-bolt" class="w-full">
|
2024-06-10 05:24:55 +02:00
|
|
|
Open Moderation Panel
|
2024-06-21 04:09:09 +02:00
|
|
|
</ButtonDropdown>
|
2024-06-10 05:24:55 +02:00
|
|
|
</Menu.Item>
|
|
|
|
|
</Menu.ItemGroup>
|
2024-04-28 08:35:26 +02:00
|
|
|
</template>
|
2024-06-21 04:09:09 +02:00
|
|
|
</AdaptiveDropdown>
|
2024-04-28 08:35:26 +02:00
|
|
|
</div>
|
|
|
|
|
</Skeleton>
|
2024-06-10 06:33:14 +02:00
|
|
|
</article>
|
2024-04-22 09:38:51 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-06-05 02:03:15 +02:00
|
|
|
import { Menu } from "@ark-ui/vue";
|
2024-06-20 01:57:38 +02:00
|
|
|
import { RolePermission, type Status } from "@lysand-org/client/types";
|
2024-06-21 04:09:09 +02:00
|
|
|
import Avatar from "~/components/avatars/avatar.vue";
|
|
|
|
|
import ButtonDropdown from "~/components/buttons/button-dropdown.vue";
|
|
|
|
|
import AdaptiveDropdown from "~/components/dropdowns/AdaptiveDropdown.vue";
|
2024-04-22 09:38:51 +02:00
|
|
|
import Skeleton from "~/components/skeleton/Skeleton.vue";
|
2024-06-21 04:09:09 +02:00
|
|
|
import Header from "./header.vue";
|
|
|
|
|
import NoteContent from "./note-content.vue";
|
|
|
|
|
import ReplyHeader from "./reply-header.vue";
|
2024-04-22 09:38:51 +02:00
|
|
|
|
2024-04-28 08:35:26 +02:00
|
|
|
const props = withDefaults(
|
|
|
|
|
defineProps<{
|
|
|
|
|
note?: Status;
|
|
|
|
|
small?: boolean;
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
showInteractions?: boolean;
|
|
|
|
|
}>(),
|
|
|
|
|
{
|
|
|
|
|
showInteractions: true,
|
|
|
|
|
},
|
|
|
|
|
);
|
2024-04-22 09:38:51 +02:00
|
|
|
|
2024-06-05 02:03:15 +02:00
|
|
|
const noteRef = ref(props.note);
|
|
|
|
|
|
2024-06-06 08:42:44 +02:00
|
|
|
useListen("composer:send-edit", (note) => {
|
|
|
|
|
if (note.id === noteRef.value?.id) {
|
|
|
|
|
noteRef.value = note;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-10 05:24:55 +02:00
|
|
|
const client = useClient();
|
|
|
|
|
const identity = useCurrentIdentity();
|
2024-06-19 08:16:28 +02:00
|
|
|
const settings = useSettings();
|
2024-04-28 07:02:27 +02:00
|
|
|
const {
|
|
|
|
|
loaded,
|
2024-06-06 08:42:44 +02:00
|
|
|
note: outputtedNote,
|
2024-04-28 07:02:27 +02:00
|
|
|
remove,
|
|
|
|
|
content,
|
|
|
|
|
shouldHide,
|
|
|
|
|
url,
|
2024-04-28 08:35:26 +02:00
|
|
|
isQuote,
|
2024-04-28 07:02:27 +02:00
|
|
|
reblog,
|
2024-05-12 04:33:40 +02:00
|
|
|
isReply,
|
2024-04-28 07:02:27 +02:00
|
|
|
reblogDisplayName,
|
2024-06-19 08:16:28 +02:00
|
|
|
} = useNoteData(noteRef, client, settings);
|
2024-04-28 07:02:27 +02:00
|
|
|
|
2024-06-10 05:24:55 +02:00
|
|
|
const openBlank = (url: string) => window.open(url, "_blank");
|
|
|
|
|
|
2024-04-25 08:56:01 +02:00
|
|
|
const { copy } = useClipboard();
|
2024-06-10 05:24:55 +02:00
|
|
|
const isMyAccount = computed(
|
|
|
|
|
() => identity.value?.account.id === outputtedNote.value?.account.id,
|
|
|
|
|
);
|
|
|
|
|
const isRemote = computed(() =>
|
|
|
|
|
outputtedNote.value?.account.acct.includes("@"),
|
|
|
|
|
);
|
|
|
|
|
const permissions = usePermissions();
|
2024-04-25 08:56:01 +02:00
|
|
|
const numberFormat = (number = 0) =>
|
|
|
|
|
new Intl.NumberFormat(undefined, {
|
|
|
|
|
notation: "compact",
|
|
|
|
|
compactDisplay: "short",
|
|
|
|
|
maximumFractionDigits: 1,
|
|
|
|
|
}).format(number);
|
2024-06-05 02:03:15 +02:00
|
|
|
|
|
|
|
|
const likeFn = async () => {
|
2024-06-20 02:07:56 +02:00
|
|
|
if (!outputtedNote.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-06-06 08:42:44 +02:00
|
|
|
if (outputtedNote.value.favourited) {
|
2024-06-10 05:24:55 +02:00
|
|
|
const output = await client.value.unfavouriteStatus(
|
2024-06-06 08:42:44 +02:00
|
|
|
outputtedNote.value.id,
|
|
|
|
|
);
|
2024-06-05 02:03:15 +02:00
|
|
|
|
|
|
|
|
if (output?.data) {
|
|
|
|
|
noteRef.value = output.data;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2024-06-10 05:24:55 +02:00
|
|
|
const output = await client.value.favouriteStatus(
|
2024-06-06 08:42:44 +02:00
|
|
|
outputtedNote.value.id,
|
|
|
|
|
);
|
2024-06-05 02:03:15 +02:00
|
|
|
|
|
|
|
|
if (output?.data) {
|
|
|
|
|
noteRef.value = output.data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const reblogFn = async () => {
|
2024-06-20 02:07:56 +02:00
|
|
|
if (!outputtedNote.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-06-06 08:42:44 +02:00
|
|
|
if (outputtedNote.value?.reblogged) {
|
2024-06-10 05:24:55 +02:00
|
|
|
const output = await client.value.unreblogStatus(
|
2024-06-06 08:42:44 +02:00
|
|
|
outputtedNote.value.id,
|
|
|
|
|
);
|
2024-06-05 02:03:15 +02:00
|
|
|
|
|
|
|
|
if (output?.data) {
|
|
|
|
|
noteRef.value = output.data;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2024-06-10 05:24:55 +02:00
|
|
|
const output = await client.value.reblogStatus(outputtedNote.value.id);
|
2024-06-05 02:03:15 +02:00
|
|
|
|
|
|
|
|
if (output?.data.reblog) {
|
|
|
|
|
noteRef.value = output.data.reblog;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2024-05-12 04:15:42 +02:00
|
|
|
</script>
|