2021-11-12 14:15:14 +00:00
|
|
|
<template>
|
2022-07-24 06:45:16 +00:00
|
|
|
<button
|
|
|
|
v-if="canRenote"
|
2021-11-19 10:36:12 +00:00
|
|
|
ref="buttonRef"
|
2021-11-12 14:53:10 +00:00
|
|
|
class="eddddedb _button canRenote"
|
2021-11-12 14:15:14 +00:00
|
|
|
@click="renote()"
|
|
|
|
>
|
2022-12-19 10:01:30 +00:00
|
|
|
<i class="ti ti-repeat"></i>
|
2021-11-19 10:36:12 +00:00
|
|
|
<p v-if="count > 0" class="count">{{ count }}</p>
|
2021-11-12 14:15:14 +00:00
|
|
|
</button>
|
2021-11-12 14:54:02 +00:00
|
|
|
<button v-else class="eddddedb _button">
|
2022-12-19 10:01:30 +00:00
|
|
|
<i class="ti ti-ban"></i>
|
2021-11-12 14:15:14 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, ref } from 'vue';
|
|
|
|
import * as misskey from 'misskey-js';
|
2022-08-30 15:24:33 +00:00
|
|
|
import XDetails from '@/components/MkUsersTooltip.vue';
|
2021-11-12 14:53:10 +00:00
|
|
|
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';
|
2021-11-12 14:15:14 +00:00
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
const props = defineProps<{
|
|
|
|
note: misskey.entities.Note;
|
|
|
|
count: number;
|
|
|
|
}>();
|
2021-11-12 14:53:10 +00:00
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
const buttonRef = ref<HTMLElement>();
|
2021-11-12 14:53:10 +00:00
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id);
|
2021-11-12 14:53:10 +00:00
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
useTooltip(buttonRef, async (showing) => {
|
|
|
|
const renotes = await os.api('notes/renotes', {
|
|
|
|
noteId: props.note.id,
|
|
|
|
limit: 11,
|
|
|
|
});
|
2021-11-12 14:53:10 +00:00
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
const users = renotes.map(x => x.user);
|
2021-11-12 14:53:10 +00:00
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
if (users.length < 1) return;
|
2021-11-12 14:53:10 +00:00
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
os.popup(XDetails, {
|
|
|
|
showing,
|
|
|
|
users,
|
|
|
|
count: props.count,
|
|
|
|
targetElement: buttonRef.value,
|
|
|
|
}, {}, 'closed');
|
|
|
|
});
|
2021-11-12 14:53:10 +00:00
|
|
|
|
2022-07-24 06:45:16 +00:00
|
|
|
const renote = (viaKeyboard = false) => {
|
|
|
|
pleaseLogin();
|
|
|
|
os.popupMenu([{
|
|
|
|
text: i18n.ts.renote,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-repeat',
|
2022-07-24 06:45:16 +00:00
|
|
|
action: () => {
|
|
|
|
os.api('notes/create', {
|
|
|
|
renoteId: props.note.id,
|
2021-11-12 14:15:14 +00:00
|
|
|
});
|
2022-07-24 06:45:16 +00:00
|
|
|
},
|
|
|
|
}, {
|
|
|
|
text: i18n.ts.quote,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-quote',
|
2022-07-24 06:45:16 +00:00
|
|
|
action: () => {
|
|
|
|
os.post({
|
|
|
|
renote: props.note,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}], buttonRef.value, {
|
|
|
|
viaKeyboard,
|
|
|
|
});
|
|
|
|
};
|
2021-11-12 14:15:14 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-11-12 14:53:10 +00:00
|
|
|
.eddddedb {
|
2021-11-12 14:15:14 +00:00
|
|
|
display: inline-block;
|
|
|
|
height: 32px;
|
|
|
|
margin: 2px;
|
|
|
|
padding: 0 6px;
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
|
|
&:not(.canRenote) {
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.renoted {
|
|
|
|
background: var(--accent);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .count {
|
|
|
|
display: inline;
|
|
|
|
margin-left: 8px;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|