2021-11-12 07:15:14 -07:00
|
|
|
<template>
|
2022-07-24 00:45:16 -06:00
|
|
|
<button
|
|
|
|
v-if="canRenote"
|
2021-11-19 03:36:12 -07:00
|
|
|
ref="buttonRef"
|
2022-11-25 04:46:10 -07:00
|
|
|
v-tooltip.noDelay.bottom="i18n.ts.renote"
|
2022-11-26 22:37:23 -07:00
|
|
|
class="eddddedb _button canRenote"
|
2022-10-25 19:45:24 -06:00
|
|
|
@click="renote(false, $event)"
|
2021-11-12 07:15:14 -07:00
|
|
|
>
|
2022-11-06 19:49:47 -07:00
|
|
|
<i class="ph-repeat-bold ph-lg"></i>
|
2021-11-19 03:36:12 -07:00
|
|
|
<p v-if="count > 0" class="count">{{ count }}</p>
|
2021-11-12 07:15:14 -07:00
|
|
|
</button>
|
2021-11-12 07:54:02 -07:00
|
|
|
<button v-else class="eddddedb _button">
|
2022-11-06 19:49:47 -07:00
|
|
|
<i class="ph-prohibit-bold ph-lg"></i>
|
2021-11-12 07:15:14 -07:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2022-07-24 00:45:16 -06:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, ref } from 'vue';
|
2022-11-26 22:37:23 -07:00
|
|
|
import type * as misskey from 'misskey-js';
|
2022-10-25 12:23:59 -06:00
|
|
|
import Ripple from '@/components/MkRipple.vue';
|
2022-08-30 09:24:33 -06:00
|
|
|
import XDetails from '@/components/MkUsersTooltip.vue';
|
2021-11-12 07:53:10 -07: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';
|
2022-11-26 22:37:23 -07:00
|
|
|
import { defaultStore } from '@/store';
|
2021-11-12 07:15:14 -07:00
|
|
|
|
2022-07-24 00:45:16 -06:00
|
|
|
const props = defineProps<{
|
2022-09-05 16:00:45 -06:00
|
|
|
note: misskey.entities.Note;
|
|
|
|
count: number;
|
|
|
|
}>();
|
2021-11-12 07:53:10 -07:00
|
|
|
|
2022-07-24 00:45:16 -06:00
|
|
|
const buttonRef = ref<HTMLElement>();
|
2021-11-12 07:53:10 -07:00
|
|
|
|
2022-07-24 00:45:16 -06:00
|
|
|
const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id);
|
2021-11-12 07:53:10 -07:00
|
|
|
|
2022-07-24 00:45:16 -06:00
|
|
|
useTooltip(buttonRef, async (showing) => {
|
|
|
|
const renotes = await os.api('notes/renotes', {
|
|
|
|
noteId: props.note.id,
|
|
|
|
limit: 11,
|
|
|
|
});
|
2021-11-12 07:53:10 -07:00
|
|
|
|
2022-07-24 00:45:16 -06:00
|
|
|
const users = renotes.map(x => x.user);
|
2021-11-12 07:53:10 -07:00
|
|
|
|
2022-07-24 00:45:16 -06:00
|
|
|
if (users.length < 1) return;
|
2021-11-12 07:53:10 -07:00
|
|
|
|
2022-07-24 00:45:16 -06:00
|
|
|
os.popup(XDetails, {
|
|
|
|
showing,
|
|
|
|
users,
|
|
|
|
count: props.count,
|
|
|
|
targetElement: buttonRef.value,
|
|
|
|
}, {}, 'closed');
|
|
|
|
});
|
2021-11-12 07:53:10 -07:00
|
|
|
|
2022-12-02 00:19:37 -07:00
|
|
|
const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
|
2022-07-24 00:45:16 -06:00
|
|
|
pleaseLogin();
|
2022-12-02 00:11:11 -07:00
|
|
|
let buttonActions = [{
|
|
|
|
text: i18n.ts.renote,
|
|
|
|
icon: 'ph-repeat-bold ph-lg',
|
|
|
|
action: () => {
|
|
|
|
os.api('notes/create', {
|
|
|
|
renoteId: props.note.id,
|
|
|
|
visibility: props.note.visibility,
|
|
|
|
});
|
|
|
|
const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined;
|
|
|
|
if (el) {
|
|
|
|
const rect = el.getBoundingClientRect();
|
|
|
|
const x = rect.left + (el.offsetWidth / 2);
|
|
|
|
const y = rect.top + (el.offsetHeight / 2);
|
|
|
|
os.popup(Ripple, { x, y }, {}, 'end');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}];
|
2022-12-02 00:19:37 -07:00
|
|
|
const renotes = await os.api('notes/renotes', {
|
2022-12-02 00:11:11 -07:00
|
|
|
noteId: props.note.id,
|
|
|
|
limit: 11,
|
|
|
|
});
|
2022-12-02 00:19:37 -07:00
|
|
|
|
|
|
|
const users = renotes.map(x => x.user);
|
2022-12-02 00:11:11 -07:00
|
|
|
const hasRenotedBefore = users.includes($i);
|
|
|
|
|
|
|
|
if (hasRenotedBefore) {
|
|
|
|
buttonActions.push({
|
|
|
|
text: i18n.ts.unrenote,
|
|
|
|
icon: 'ph-eraser-bold ph-lg',
|
2022-09-28 10:22:03 -06:00
|
|
|
action: () => {
|
2022-12-02 00:11:11 -07:00
|
|
|
os.api('notes/unrenote', {
|
|
|
|
noteId: props.note.id,
|
2022-09-28 10:22:03 -06:00
|
|
|
});
|
|
|
|
},
|
2022-12-02 00:11:11 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
if (!defaultStore.state.seperateRenoteQuote) {
|
|
|
|
buttonActions.push({
|
2022-09-28 10:22:03 -06:00
|
|
|
text: i18n.ts.quote,
|
2022-11-06 19:49:47 -07:00
|
|
|
icon: 'ph-quotes-bold ph-lg',
|
2022-09-28 10:22:03 -06:00
|
|
|
action: () => {
|
|
|
|
os.post({
|
|
|
|
renote: props.note,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2022-12-02 00:11:11 -07:00
|
|
|
os.popupMenu(buttonActions, buttonRef.value, { viaKeyboard });
|
2022-07-24 00:45:16 -06:00
|
|
|
};
|
2021-11-12 07:15:14 -07:00
|
|
|
</script>
|
|
|
|
|
2022-09-05 16:00:45 -06:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.eddddedb {
|
|
|
|
display: inline-block;
|
|
|
|
height: 32px;
|
|
|
|
margin: 2px;
|
|
|
|
padding: 0 6px;
|
|
|
|
border-radius: 4px;
|
2021-11-12 07:15:14 -07:00
|
|
|
|
2022-09-05 16:00:45 -06:00
|
|
|
&:not(.canRenote) {
|
|
|
|
cursor: default;
|
|
|
|
}
|
2021-11-12 07:15:14 -07:00
|
|
|
|
2022-09-05 16:00:45 -06:00
|
|
|
&.renoted {
|
|
|
|
background: var(--accent);
|
|
|
|
}
|
2021-11-12 07:15:14 -07:00
|
|
|
|
2022-09-05 16:00:45 -06:00
|
|
|
> .count {
|
|
|
|
display: inline;
|
|
|
|
margin-left: 8px;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
2021-11-12 07:15:14 -07:00
|
|
|
}
|
2022-09-05 16:00:45 -06:00
|
|
|
</style>
|