2024-11-30 16:21:16 +01:00
|
|
|
<template>
|
|
|
|
|
<div class="flex flex-row w-full items-stretch justify-around text-sm *:max-w-28 *:w-full *:text-muted-foreground">
|
2024-12-07 22:17:22 +01:00
|
|
|
<Button variant="ghost" @click="emit('reply')" :title="m.drab_tense_turtle_comfort()" :disabled="!identity">
|
2024-11-30 16:21:16 +01:00
|
|
|
<Reply class="size-5 text-primary" />
|
|
|
|
|
{{ numberFormat(replyCount) }}
|
|
|
|
|
</Button>
|
2024-12-25 18:35:54 +01:00
|
|
|
<Button variant="ghost" @click="liked ? unlike() : like()" :title="liked ? m.vexed_fluffy_clownfish_dance() : m.royal_close_samuel_scold()" :disabled="!identity" :class="liked && '*:fill-red-600 *:text-red-600'">
|
2024-11-30 16:21:16 +01:00
|
|
|
<Heart class="size-5 text-primary" />
|
|
|
|
|
{{ numberFormat(likeCount) }}
|
|
|
|
|
</Button>
|
2024-12-25 18:35:54 +01:00
|
|
|
<Button variant="ghost" @click="reblogged ? unreblog() : reblog()" :title="reblogged ? m.lime_neat_ox_stab() : m.aware_helpful_marlin_drop()" :disabled="!identity" :class="reblogged && '*:text-green-600'">
|
2024-11-30 16:21:16 +01:00
|
|
|
<Repeat class="size-5 text-primary" />
|
|
|
|
|
{{ numberFormat(reblogCount) }}
|
|
|
|
|
</Button>
|
2024-12-07 22:17:22 +01:00
|
|
|
<Button variant="ghost" @click="emit('quote')" :title="m.true_shy_jackal_drip()" :disabled="!identity">
|
2024-11-30 16:21:16 +01:00
|
|
|
<Quote class="size-5 text-primary" />
|
|
|
|
|
</Button>
|
2024-12-01 18:54:17 +01:00
|
|
|
<Menu :api-note-string="apiNoteString" :url="url" :remote-url="remoteUrl" :is-remote="isRemote" :author-id="authorId" @edit="emit('edit')" :note-id="noteId" @delete="emit('delete')">
|
2024-12-07 22:17:22 +01:00
|
|
|
<Button variant="ghost" :title="m.busy_merry_cowfish_absorb()">
|
2024-11-30 16:21:16 +01:00
|
|
|
<Ellipsis class="size-5 text-primary" />
|
|
|
|
|
</Button>
|
|
|
|
|
</Menu>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { Ellipsis, Heart, Quote, Repeat, Reply } from "lucide-vue-next";
|
2024-12-01 18:54:17 +01:00
|
|
|
import { toast } from "vue-sonner";
|
2024-11-30 16:21:16 +01:00
|
|
|
import { Button } from "~/components/ui/button";
|
2024-12-07 22:17:22 +01:00
|
|
|
import * as m from "~/paraglide/messages.js";
|
2024-12-02 22:01:04 +01:00
|
|
|
import { SettingIds } from "~/settings";
|
|
|
|
|
import { confirmModalService } from "../modals/composable";
|
2024-11-30 16:21:16 +01:00
|
|
|
import Menu from "./menu.vue";
|
|
|
|
|
|
2024-12-01 18:54:17 +01:00
|
|
|
const { noteId } = defineProps<{
|
2024-11-30 16:21:16 +01:00
|
|
|
replyCount: number;
|
|
|
|
|
likeCount: number;
|
|
|
|
|
reblogCount: number;
|
2024-11-30 18:21:40 +01:00
|
|
|
apiNoteString: string;
|
2024-12-01 18:54:17 +01:00
|
|
|
noteId: string;
|
2024-11-30 18:21:40 +01:00
|
|
|
isRemote: boolean;
|
|
|
|
|
url: string;
|
|
|
|
|
remoteUrl: string;
|
|
|
|
|
authorId: string;
|
2024-12-01 18:54:17 +01:00
|
|
|
liked: boolean;
|
|
|
|
|
reblogged: boolean;
|
2024-11-30 16:21:16 +01:00
|
|
|
}>();
|
|
|
|
|
|
2024-12-01 18:29:54 +01:00
|
|
|
const emit = defineEmits<{
|
|
|
|
|
edit: [];
|
|
|
|
|
reply: [];
|
|
|
|
|
quote: [];
|
2024-12-01 18:54:17 +01:00
|
|
|
delete: [];
|
2024-12-01 18:29:54 +01:00
|
|
|
}>();
|
2024-12-25 18:15:09 +01:00
|
|
|
const { play } = useAudio();
|
2024-12-01 18:29:54 +01:00
|
|
|
|
2024-12-02 22:01:04 +01:00
|
|
|
const confirmLikes = useSetting(SettingIds.ConfirmLike);
|
|
|
|
|
const confirmReblogs = useSetting(SettingIds.ConfirmReblog);
|
|
|
|
|
|
2024-12-01 18:54:17 +01:00
|
|
|
const like = async () => {
|
2024-12-02 22:01:04 +01:00
|
|
|
if (confirmLikes.value.value) {
|
|
|
|
|
const confirmation = await confirmModalService.confirm({
|
2024-12-07 22:17:22 +01:00
|
|
|
title: m.slimy_least_ray_aid(),
|
|
|
|
|
message: m.stale_new_ray_jolt(),
|
|
|
|
|
confirmText: m.royal_close_samuel_scold(),
|
2024-12-02 22:01:04 +01:00
|
|
|
inputType: "none",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!confirmation.confirmed) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-25 18:15:09 +01:00
|
|
|
play("like");
|
2024-12-07 22:17:22 +01:00
|
|
|
const id = toast.loading(m.slimy_candid_tiger_read());
|
2024-12-01 18:54:17 +01:00
|
|
|
const { data } = await client.value.favouriteStatus(noteId);
|
|
|
|
|
toast.dismiss(id);
|
2024-12-07 22:17:22 +01:00
|
|
|
toast.success(m.mealy_slow_buzzard_commend());
|
2024-12-01 18:54:17 +01:00
|
|
|
useEvent("note:edit", data);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const unlike = async () => {
|
2024-12-02 22:01:04 +01:00
|
|
|
if (confirmLikes.value.value) {
|
|
|
|
|
const confirmation = await confirmModalService.confirm({
|
2024-12-07 22:17:22 +01:00
|
|
|
title: m.odd_strong_halibut_prosper(),
|
|
|
|
|
message: m.slow_blue_parrot_savor(),
|
|
|
|
|
confirmText: m.vexed_fluffy_clownfish_dance(),
|
2024-12-02 22:01:04 +01:00
|
|
|
inputType: "none",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!confirmation.confirmed) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-07 22:17:22 +01:00
|
|
|
const id = toast.loading(m.busy_active_leopard_strive());
|
2024-12-01 18:54:17 +01:00
|
|
|
const { data } = await client.value.unfavouriteStatus(noteId);
|
|
|
|
|
toast.dismiss(id);
|
2024-12-07 22:17:22 +01:00
|
|
|
toast.success(m.fresh_direct_bear_affirm());
|
2024-12-01 18:54:17 +01:00
|
|
|
useEvent("note:edit", data);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const reblog = async () => {
|
2024-12-02 22:01:04 +01:00
|
|
|
if (confirmReblogs.value.value) {
|
|
|
|
|
const confirmation = await confirmModalService.confirm({
|
2024-12-07 22:17:22 +01:00
|
|
|
title: m.best_mellow_llama_surge(),
|
|
|
|
|
message: m.salty_plain_mallard_gaze(),
|
|
|
|
|
confirmText: m.aware_helpful_marlin_drop(),
|
2024-12-02 22:01:04 +01:00
|
|
|
inputType: "none",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!confirmation.confirmed) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-07 22:17:22 +01:00
|
|
|
const id = toast.loading(m.late_sunny_cobra_scold());
|
2024-12-01 18:54:17 +01:00
|
|
|
const { data } = await client.value.reblogStatus(noteId);
|
|
|
|
|
toast.dismiss(id);
|
2024-12-07 22:17:22 +01:00
|
|
|
toast.success(m.weird_moving_hawk_lift());
|
2024-12-01 18:54:17 +01:00
|
|
|
useEvent("note:edit", data.reblog || data);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const unreblog = async () => {
|
2024-12-02 22:01:04 +01:00
|
|
|
if (confirmReblogs.value.value) {
|
|
|
|
|
const confirmation = await confirmModalService.confirm({
|
2024-12-07 22:17:22 +01:00
|
|
|
title: m.main_fancy_octopus_loop(),
|
|
|
|
|
message: m.odd_alive_swan_express(),
|
|
|
|
|
confirmText: m.lime_neat_ox_stab(),
|
2024-12-02 22:01:04 +01:00
|
|
|
inputType: "none",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!confirmation.confirmed) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-07 22:17:22 +01:00
|
|
|
const id = toast.loading(m.white_sharp_gorilla_embrace());
|
2024-12-01 18:54:17 +01:00
|
|
|
const { data } = await client.value.unreblogStatus(noteId);
|
|
|
|
|
toast.dismiss(id);
|
2024-12-07 22:17:22 +01:00
|
|
|
toast.success(m.royal_polite_moose_catch());
|
2024-12-01 18:54:17 +01:00
|
|
|
useEvent("note:edit", data);
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-30 16:21:16 +01:00
|
|
|
const numberFormat = (number = 0) =>
|
|
|
|
|
number !== 0
|
2024-12-07 23:05:26 +01:00
|
|
|
? new Intl.NumberFormat(getLanguageTag(), {
|
2024-11-30 16:21:16 +01:00
|
|
|
notation: "compact",
|
|
|
|
|
compactDisplay: "short",
|
|
|
|
|
maximumFractionDigits: 1,
|
|
|
|
|
}).format(number)
|
|
|
|
|
: undefined;
|
2024-12-25 18:15:09 +01:00
|
|
|
</script>
|