2021-11-12 23:15:14 +09:00
|
|
|
<template>
|
2021-11-12 23:54:02 +09:00
|
|
|
<button v-if="canRenote"
|
2021-11-19 19:36:12 +09:00
|
|
|
ref="buttonRef"
|
2021-11-12 23:53:10 +09:00
|
|
|
class="eddddedb _button canRenote"
|
2021-11-12 23:15:14 +09:00
|
|
|
@click="renote()"
|
|
|
|
>
|
|
|
|
<i class="fas fa-retweet"></i>
|
2021-11-19 19:36:12 +09:00
|
|
|
<p v-if="count > 0" class="count">{{ count }}</p>
|
2021-11-12 23:15:14 +09:00
|
|
|
</button>
|
2021-11-12 23:54:02 +09:00
|
|
|
<button v-else class="eddddedb _button">
|
2021-11-12 23:15:14 +09:00
|
|
|
<i class="fas fa-ban"></i>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-11-12 23:53:10 +09:00
|
|
|
import { computed, defineComponent, ref } from 'vue';
|
|
|
|
import XDetails from '@/components/renote.details.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';
|
2021-11-12 23:15:14 +09:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
count: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
note: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2021-11-12 23:53:10 +09:00
|
|
|
|
|
|
|
setup(props) {
|
|
|
|
const buttonRef = ref<HTMLElement>();
|
|
|
|
|
|
|
|
const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id);
|
|
|
|
|
2021-12-05 20:01:52 +09:00
|
|
|
useTooltip(buttonRef, async (showing) => {
|
2021-11-12 23:53:10 +09:00
|
|
|
const renotes = await os.api('notes/renotes', {
|
|
|
|
noteId: props.note.id,
|
|
|
|
limit: 11
|
|
|
|
});
|
|
|
|
|
2021-11-21 14:09:41 +09:00
|
|
|
const users = renotes.map(x => x.user);
|
2021-11-12 23:53:10 +09:00
|
|
|
|
|
|
|
if (users.length < 1) return;
|
|
|
|
|
|
|
|
os.popup(XDetails, {
|
|
|
|
showing,
|
|
|
|
users,
|
|
|
|
count: props.count,
|
|
|
|
source: buttonRef.value
|
|
|
|
}, {}, 'closed');
|
|
|
|
});
|
|
|
|
|
|
|
|
const renote = (viaKeyboard = false) => {
|
2021-11-12 23:15:14 +09:00
|
|
|
pleaseLogin();
|
|
|
|
os.popupMenu([{
|
2021-11-12 23:53:10 +09:00
|
|
|
text: i18n.locale.renote,
|
2021-11-12 23:15:14 +09:00
|
|
|
icon: 'fas fa-retweet',
|
|
|
|
action: () => {
|
|
|
|
os.api('notes/create', {
|
2021-11-12 23:53:10 +09:00
|
|
|
renoteId: props.note.id
|
2021-11-12 23:15:14 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}, {
|
2021-11-12 23:53:10 +09:00
|
|
|
text: i18n.locale.quote,
|
2021-11-12 23:15:14 +09:00
|
|
|
icon: 'fas fa-quote-right',
|
|
|
|
action: () => {
|
|
|
|
os.post({
|
2021-11-12 23:53:10 +09:00
|
|
|
renote: props.note,
|
2021-11-12 23:15:14 +09:00
|
|
|
});
|
|
|
|
}
|
2021-11-12 23:53:10 +09:00
|
|
|
}], buttonRef.value, {
|
2021-11-12 23:15:14 +09:00
|
|
|
viaKeyboard
|
|
|
|
});
|
2021-11-12 23:53:10 +09:00
|
|
|
};
|
2021-11-12 23:15:14 +09:00
|
|
|
|
2021-11-12 23:53:10 +09:00
|
|
|
return {
|
|
|
|
buttonRef,
|
|
|
|
canRenote,
|
|
|
|
renote,
|
|
|
|
};
|
|
|
|
},
|
2021-11-12 23:15:14 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-11-12 23:53:10 +09:00
|
|
|
.eddddedb {
|
2021-11-12 23:15:14 +09: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>
|