summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkRenoteButton.vue
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-12-27 14:36:33 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-12-27 14:36:33 +0900
commit9384f5399da39e53855beb8e7f8ded1aa56bf72e (patch)
treece5959571a981b9c4047da3c7b3fd080aa44222c /packages/frontend/src/components/MkRenoteButton.vue
parentwip: retention for dashboard (diff)
downloadsharkey-9384f5399da39e53855beb8e7f8ded1aa56bf72e.tar.gz
sharkey-9384f5399da39e53855beb8e7f8ded1aa56bf72e.tar.bz2
sharkey-9384f5399da39e53855beb8e7f8ded1aa56bf72e.zip
rename: client -> frontend
Diffstat (limited to 'packages/frontend/src/components/MkRenoteButton.vue')
-rw-r--r--packages/frontend/src/components/MkRenoteButton.vue99
1 files changed, 99 insertions, 0 deletions
diff --git a/packages/frontend/src/components/MkRenoteButton.vue b/packages/frontend/src/components/MkRenoteButton.vue
new file mode 100644
index 0000000000..e0b1eaafc9
--- /dev/null
+++ b/packages/frontend/src/components/MkRenoteButton.vue
@@ -0,0 +1,99 @@
+<template>
+<button
+ v-if="canRenote"
+ ref="buttonRef"
+ class="eddddedb _button canRenote"
+ @click="renote()"
+>
+ <i class="ti ti-repeat"></i>
+ <p v-if="count > 0" class="count">{{ count }}</p>
+</button>
+<button v-else class="eddddedb _button">
+ <i class="ti ti-ban"></i>
+</button>
+</template>
+
+<script lang="ts" setup>
+import { computed, ref } from 'vue';
+import * as misskey from 'misskey-js';
+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';
+
+const props = defineProps<{
+ note: misskey.entities.Note;
+ count: number;
+}>();
+
+const buttonRef = ref<HTMLElement>();
+
+const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id);
+
+useTooltip(buttonRef, async (showing) => {
+ const renotes = await os.api('notes/renotes', {
+ noteId: props.note.id,
+ limit: 11,
+ });
+
+ const users = renotes.map(x => x.user);
+
+ if (users.length < 1) return;
+
+ os.popup(XDetails, {
+ showing,
+ users,
+ count: props.count,
+ targetElement: buttonRef.value,
+ }, {}, 'closed');
+});
+
+const renote = (viaKeyboard = false) => {
+ pleaseLogin();
+ os.popupMenu([{
+ text: i18n.ts.renote,
+ icon: 'ti ti-repeat',
+ action: () => {
+ os.api('notes/create', {
+ renoteId: props.note.id,
+ });
+ },
+ }, {
+ text: i18n.ts.quote,
+ icon: 'ti ti-quote',
+ action: () => {
+ os.post({
+ renote: props.note,
+ });
+ },
+ }], buttonRef.value, {
+ viaKeyboard,
+ });
+};
+</script>
+
+<style lang="scss" scoped>
+.eddddedb {
+ 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>