2021-11-12 15:15:14 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<button
|
|
|
|
v-if="canRenote"
|
|
|
|
ref="buttonRef"
|
|
|
|
v-tooltip.noDelay.bottom="i18n.ts.renote"
|
2023-05-24 02:30:55 +02:00
|
|
|
class="button _button canRenote"
|
2023-06-03 18:57:51 +02:00
|
|
|
:class="{ renoted: hasRenotedBefore }"
|
2023-04-08 02:01:42 +02:00
|
|
|
@click="renote(false, $event)"
|
|
|
|
>
|
|
|
|
<i class="ph-repeat ph-bold ph-lg"></i>
|
2023-05-19 19:02:41 +02:00
|
|
|
<p v-if="count > 0 && !detailedView" class="count">{{ count }}</p>
|
2023-04-08 02:01:42 +02:00
|
|
|
</button>
|
|
|
|
<button v-else class="eddddedb _button">
|
|
|
|
<i class="ph-prohibit ph-bold ph-lg"></i>
|
|
|
|
</button>
|
2021-11-12 15:15:14 +01:00
|
|
|
</template>
|
|
|
|
|
2022-07-24 08:45:16 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { computed, ref } from "vue";
|
|
|
|
import type * as misskey from "calckey-js";
|
|
|
|
import Ripple from "@/components/MkRipple.vue";
|
|
|
|
import XDetails from "@/components/MkUsersTooltip.vue";
|
|
|
|
import { pleaseLogin } from "@/scripts/please-login";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { $i } from "@/account";
|
|
|
|
import { useTooltip } from "@/scripts/use-tooltip";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { defaultStore } from "@/store";
|
2023-05-07 01:26:24 +02:00
|
|
|
import { MenuItem } from "@/types/menu";
|
2021-11-12 15:15:14 +01:00
|
|
|
|
2022-07-24 08:45:16 +02:00
|
|
|
const props = defineProps<{
|
2023-04-08 02:01:42 +02:00
|
|
|
note: misskey.entities.Note;
|
|
|
|
count: number;
|
2023-05-19 19:02:41 +02:00
|
|
|
detailedView?;
|
2023-04-08 02:01:42 +02:00
|
|
|
}>();
|
2021-11-12 15:53:10 +01:00
|
|
|
|
2022-07-24 08:45:16 +02:00
|
|
|
const buttonRef = ref<HTMLElement>();
|
2021-11-12 15:53:10 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const canRenote = computed(
|
|
|
|
() =>
|
2023-05-08 03:01:36 +02:00
|
|
|
["public", "home"].includes(props.note.visibility) ||
|
2023-04-08 02:01:42 +02:00
|
|
|
props.note.userId === $i.id
|
|
|
|
);
|
2021-11-12 15:53:10 +01:00
|
|
|
|
2022-07-24 08:45:16 +02:00
|
|
|
useTooltip(buttonRef, async (showing) => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const renotes = await os.api("notes/renotes", {
|
2022-07-24 08:45:16 +02:00
|
|
|
noteId: props.note.id,
|
|
|
|
limit: 11,
|
|
|
|
});
|
2021-11-12 15:53:10 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const users = renotes.map((x) => x.user);
|
2021-11-12 15:53:10 +01:00
|
|
|
|
2022-07-24 08:45:16 +02:00
|
|
|
if (users.length < 1) return;
|
2021-11-12 15:53:10 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
os.popup(
|
|
|
|
XDetails,
|
|
|
|
{
|
|
|
|
showing,
|
|
|
|
users,
|
|
|
|
count: props.count,
|
|
|
|
targetElement: buttonRef.value,
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
"closed"
|
|
|
|
);
|
2022-07-24 08:45:16 +02:00
|
|
|
});
|
2021-11-12 15:53:10 +01:00
|
|
|
|
2023-06-03 18:57:51 +02:00
|
|
|
let hasRenotedBefore = $ref(false);
|
|
|
|
os.api("notes/renotes", {
|
|
|
|
noteId: props.note.id,
|
|
|
|
userId: $i.id,
|
|
|
|
limit: 1,
|
|
|
|
}).then((res) => {
|
|
|
|
hasRenotedBefore = res.length > 0;
|
|
|
|
});
|
2022-12-02 08:37:25 +01:00
|
|
|
|
2023-06-03 18:57:51 +02:00
|
|
|
const renote = (viaKeyboard = false, ev?: MouseEvent) => {
|
|
|
|
pleaseLogin();
|
2022-12-02 08:37:25 +01:00
|
|
|
|
2023-05-07 01:26:24 +02:00
|
|
|
let buttonActions: Array<MenuItem> = [];
|
2023-04-01 08:53:29 +02:00
|
|
|
|
2023-05-08 03:01:36 +02:00
|
|
|
if (props.note.visibility === "public") {
|
2023-04-01 08:53:29 +02:00
|
|
|
buttonActions.push({
|
|
|
|
text: i18n.ts.renote,
|
2023-04-08 02:01:42 +02:00
|
|
|
icon: "ph-repeat ph-bold ph-lg",
|
2023-04-01 08:53:29 +02:00
|
|
|
danger: false,
|
|
|
|
action: () => {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("notes/create", {
|
2023-04-01 08:53:29 +02:00
|
|
|
renoteId: props.note.id,
|
2023-04-08 02:01:42 +02:00
|
|
|
visibility: "public",
|
2023-04-01 08:53:29 +02:00
|
|
|
});
|
2023-06-03 18:57:51 +02:00
|
|
|
hasRenotedBefore = true;
|
2023-04-08 02:01:42 +02:00
|
|
|
const el =
|
|
|
|
ev &&
|
|
|
|
((ev.currentTarget ?? ev.target) as
|
|
|
|
| HTMLElement
|
|
|
|
| null
|
|
|
|
| undefined);
|
2023-04-01 08:53:29 +02:00
|
|
|
if (el) {
|
|
|
|
const rect = el.getBoundingClientRect();
|
2023-04-08 02:01:42 +02:00
|
|
|
const x = rect.left + el.offsetWidth / 2;
|
|
|
|
const y = rect.top + el.offsetHeight / 2;
|
|
|
|
os.popup(Ripple, { x, y }, {}, "end");
|
2023-04-01 08:53:29 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-05-08 03:01:36 +02:00
|
|
|
if (["public", "home"].includes(props.note.visibility)) {
|
2023-04-01 08:53:29 +02:00
|
|
|
buttonActions.push({
|
2023-04-13 04:58:42 +02:00
|
|
|
text: `${i18n.ts.renote} (${i18n.ts._visibility.home})`,
|
2023-05-06 02:43:34 +02:00
|
|
|
icon: "ph-house ph-bold ph-lg",
|
2023-04-01 08:53:29 +02:00
|
|
|
danger: false,
|
|
|
|
action: () => {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("notes/create", {
|
2023-04-01 08:53:29 +02:00
|
|
|
renoteId: props.note.id,
|
2023-04-08 02:01:42 +02:00
|
|
|
visibility: "home",
|
2023-04-01 08:53:29 +02:00
|
|
|
});
|
2023-06-03 18:57:51 +02:00
|
|
|
hasRenotedBefore = true;
|
2023-04-08 02:01:42 +02:00
|
|
|
const el =
|
|
|
|
ev &&
|
|
|
|
((ev.currentTarget ?? ev.target) as
|
|
|
|
| HTMLElement
|
|
|
|
| null
|
|
|
|
| undefined);
|
2023-04-01 08:53:29 +02:00
|
|
|
if (el) {
|
|
|
|
const rect = el.getBoundingClientRect();
|
2023-04-08 02:01:42 +02:00
|
|
|
const x = rect.left + el.offsetWidth / 2;
|
|
|
|
const y = rect.top + el.offsetHeight / 2;
|
|
|
|
os.popup(Ripple, { x, y }, {}, "end");
|
2023-04-01 08:53:29 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
if (props.note.visibility === "specified") {
|
2023-04-01 08:53:29 +02:00
|
|
|
buttonActions.push({
|
2023-04-13 04:58:42 +02:00
|
|
|
text: `${i18n.ts.renote} (${i18n.ts.recipient})`,
|
2023-05-06 02:43:34 +02:00
|
|
|
icon: "ph-envelope-simple-open ph-bold ph-lg",
|
2023-04-01 08:53:29 +02:00
|
|
|
danger: false,
|
|
|
|
action: () => {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("notes/create", {
|
2023-04-01 08:53:29 +02:00
|
|
|
renoteId: props.note.id,
|
2023-04-08 02:01:42 +02:00
|
|
|
visibility: "specified",
|
2023-04-01 08:53:29 +02:00
|
|
|
visibleUserIds: props.note.visibleUserIds,
|
|
|
|
});
|
2023-06-03 18:57:51 +02:00
|
|
|
hasRenotedBefore = true;
|
2023-04-08 02:01:42 +02:00
|
|
|
const el =
|
|
|
|
ev &&
|
|
|
|
((ev.currentTarget ?? ev.target) as
|
|
|
|
| HTMLElement
|
|
|
|
| null
|
|
|
|
| undefined);
|
2023-04-01 08:53:29 +02:00
|
|
|
if (el) {
|
|
|
|
const rect = el.getBoundingClientRect();
|
2023-04-08 02:01:42 +02:00
|
|
|
const x = rect.left + el.offsetWidth / 2;
|
|
|
|
const y = rect.top + el.offsetHeight / 2;
|
|
|
|
os.popup(Ripple, { x, y }, {}, "end");
|
2023-04-01 08:53:29 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
buttonActions.push({
|
2023-04-13 04:58:42 +02:00
|
|
|
text: `${i18n.ts.renote} (${i18n.ts._visibility.followers})`,
|
2023-05-27 20:10:15 +02:00
|
|
|
icon: "ph-lock ph-bold ph-lg",
|
2023-04-01 08:53:29 +02:00
|
|
|
danger: false,
|
|
|
|
action: () => {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("notes/create", {
|
2023-04-01 08:53:29 +02:00
|
|
|
renoteId: props.note.id,
|
2023-04-08 02:01:42 +02:00
|
|
|
visibility: "followers",
|
2023-04-01 08:53:29 +02:00
|
|
|
});
|
2023-06-03 18:57:51 +02:00
|
|
|
hasRenotedBefore = true;
|
2023-04-08 02:01:42 +02:00
|
|
|
const el =
|
|
|
|
ev &&
|
|
|
|
((ev.currentTarget ?? ev.target) as
|
|
|
|
| HTMLElement
|
|
|
|
| null
|
|
|
|
| undefined);
|
2023-04-01 08:53:29 +02:00
|
|
|
if (el) {
|
|
|
|
const rect = el.getBoundingClientRect();
|
2023-04-08 02:01:42 +02:00
|
|
|
const x = rect.left + el.offsetWidth / 2;
|
|
|
|
const y = rect.top + el.offsetHeight / 2;
|
|
|
|
os.popup(Ripple, { x, y }, {}, "end");
|
2023-04-01 08:53:29 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2022-12-02 08:19:37 +01:00
|
|
|
|
2023-05-11 13:10:19 +02:00
|
|
|
if (canRenote) {
|
2023-05-07 01:26:24 +02:00
|
|
|
buttonActions.push({
|
2023-05-11 13:10:19 +02:00
|
|
|
text: `${i18n.ts.renote} (${i18n.ts.local})`,
|
2023-05-11 13:28:32 +02:00
|
|
|
icon: "ph-hand-fist ph-bold ph-lg",
|
2023-05-11 13:10:19 +02:00
|
|
|
danger: false,
|
|
|
|
action: () => {
|
2023-05-11 13:28:32 +02:00
|
|
|
os.api(
|
|
|
|
"notes/create",
|
2023-05-11 13:10:19 +02:00
|
|
|
props.note.visibility === "specified"
|
2023-05-11 13:28:32 +02:00
|
|
|
? {
|
|
|
|
renoteId: props.note.id,
|
|
|
|
visibility: props.note.visibility,
|
|
|
|
visibleUserIds: props.note.visibleUserIds,
|
|
|
|
localOnly: true,
|
|
|
|
}
|
|
|
|
: {
|
|
|
|
renoteId: props.note.id,
|
|
|
|
visibility: props.note.visibility,
|
|
|
|
localOnly: true,
|
|
|
|
}
|
|
|
|
);
|
2023-06-03 18:57:51 +02:00
|
|
|
hasRenotedBefore = true;
|
2023-05-11 13:10:19 +02:00
|
|
|
const el =
|
|
|
|
ev &&
|
|
|
|
((ev.currentTarget ?? ev.target) as
|
|
|
|
| HTMLElement
|
|
|
|
| null
|
|
|
|
| undefined);
|
|
|
|
if (el) {
|
|
|
|
const rect = el.getBoundingClientRect();
|
2023-04-08 02:01:42 +02:00
|
|
|
const x = rect.left + el.offsetWidth / 2;
|
|
|
|
const y = rect.top + el.offsetHeight / 2;
|
|
|
|
os.popup(Ripple, { x, y }, {}, "end");
|
2023-04-01 08:53:29 +02:00
|
|
|
}
|
|
|
|
},
|
2023-05-07 01:26:24 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-05-07 20:38:39 +02:00
|
|
|
if (!defaultStore.state.seperateRenoteQuote) {
|
2022-12-02 08:11:11 +01:00
|
|
|
buttonActions.push({
|
2022-09-28 18:22:03 +02:00
|
|
|
text: i18n.ts.quote,
|
2023-04-08 02:01:42 +02:00
|
|
|
icon: "ph-quotes ph-bold ph-lg",
|
2022-12-02 08:28:16 +01:00
|
|
|
danger: false,
|
2022-09-28 18:22:03 +02:00
|
|
|
action: () => {
|
|
|
|
os.post({
|
|
|
|
renote: props.note,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2022-12-02 08:37:25 +01:00
|
|
|
|
|
|
|
if (hasRenotedBefore) {
|
|
|
|
buttonActions.push({
|
|
|
|
text: i18n.ts.unrenote,
|
2023-04-08 02:01:42 +02:00
|
|
|
icon: "ph-trash ph-bold ph-lg",
|
2022-12-02 08:37:25 +01:00
|
|
|
danger: true,
|
|
|
|
action: () => {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("notes/unrenote", {
|
2022-12-02 08:37:25 +01:00
|
|
|
noteId: props.note.id,
|
|
|
|
});
|
2023-06-03 18:57:51 +02:00
|
|
|
hasRenotedBefore = false;
|
2022-12-02 08:37:25 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2023-06-13 02:06:42 +02:00
|
|
|
|
|
|
|
buttonActions[0].textStyle = "font-weight: bold";
|
|
|
|
|
2023-05-07 20:38:39 +02:00
|
|
|
os.popupMenu(buttonActions, buttonRef.value, { viaKeyboard });
|
2022-07-24 08:45:16 +02:00
|
|
|
};
|
2021-11-12 15:15:14 +01:00
|
|
|
</script>
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
<style lang="scss" scoped>
|
2023-05-24 02:30:55 +02:00
|
|
|
.button {
|
2023-04-08 02:01:42 +02:00
|
|
|
&:not(.canRenote) {
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
&.renoted {
|
2023-06-03 18:57:51 +02:00
|
|
|
color: var(--accent) !important;
|
|
|
|
opacity: 1 !important;
|
2023-06-03 19:43:08 +02:00
|
|
|
font-weight: 700;
|
2023-04-08 02:01:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|