forked from mirror/misskey
a6a91fec3a
* add: safeFloatParserを追加
* fix: 欠けていた型を追加
* refactor: pageBlockTypesをjson-schemaに移植
* refactor: components/global内の型エラーが出ている箇所を修正
* lint: fix null check style
* refactor: fix type error
* refactor: fix some type errors
* fix: 翻訳が抜けていた箇所を修正
* refactor: getJsonSchemaで正しいスキーマが返されるように修正
* fix: MkChartの型エラーとbytesオプションが機能していない問題を修正
* fix(misskey-js): `drive`->`folderUpdated`のpayloadの型が間違っていたのを修正
* refactor: fix some type errors
* change: Captcha読み込み中の文言をLoadingに変更
* refactor(backend/misskey-js): MainEventの型を改善
* refactor: chartjs-plugin-gradientが二重でpluginに登録されていたのを修正
* update: misskey-js.api.md
* refactor: fix some type errors
* fix: backendのtypecheckが落ちていたのを修正
* update: misskey-js.api.md
* add: json-schemaのnoteにpollの型定義を追加
* refactor: noteのjson-schemaの型を改善
* refactor: MkPoll
* refactor: fix some type errors
* change: UserLiteにisLockedを持たせるように
* fix: notificationスキーマにroleが含まれていないのを修正
* Revert "change: UserLiteにisLockedを持たせるように"
This reverts commit 1bb0c8e7a9
.
* fix: フォロー通知から鍵垢へのフォローを行うと処理中のまま止まってしまう問題を修正
* refactor: noteスキーマのvisibilityにenumを追加
* change: deepCloneのCloneableTypeにundefinedを追加
* refactor: fix some type errors
* refactor: `allowEmpty: false`を使用していた箇所を`minLength: 1`に置き換え
* enhance: API 'retension' のresponseの型を追加
* fix: Chart関連のtooltipが正しい位置に表示されない問題を修正
* refactor: fix some type errors
* fix: 型情報が不足していたのを修正
* enhance: announcementスキーマにenumを追加
* enhance: ロールポリシーの型定義をRoleServiceからjson-schemaに移植
* refactor: policiesを`ref: RolePolicies`に統一
* fix: API `meta` のレスポンスの型にpoliciesが含まれていないのを修正
* refactor: fix some type errors
* fix: backendのlintが落ちているのを修正
* fix: MkFoldableSectionの開閉時のanimationが適用されていない問題を修正
* fix: backendのtypecheckが落ちているのを修正
* update: run build-misskey-js-with-types
* fix: MkDialogのmount時に文字数制限の判定が行われない問題を修正
* update: CHANGELOG.md
* refactor: MkUserSelectDialogの型を改善
* fix: deepCloneでundefinedはcloneしないように (#9207)
* change: frontendのcloneをbackend側にも反映
* update: CHANGELOG.md
* fix: RoleServiceからPackを通して型RolePoliciesに依存させないように
* Update packages/frontend/src/scripts/get-note-summary.ts
* revert RoleService.ts changes
* change: optional chaining -> non-null assertion
* remove: unused import
* fix: propsで渡されたuserがUserLiteの場合に意図しない動作になってしまうのを修正
* change: fix null check style
* refactor: fix type error
* change: fix null check style
* Update packages/frontend/src/components/MkDrive.vue
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
* refactor: css moduleでglobalを使わないように
* refactor: roleのiconUrlは必ず存在するものとして扱うように
* enhance: MenuButtonのactiveにcomputedを受け付けられるように
* Update packages/frontend/src/components/MkNotePreview.vue
* Update MkWindow.vue
* refactor: notification.noteは必ず存在するものとして扱うように
* Update packages/frontend/src/components/MkNotification.vue
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
* fix: MkSignupDialogでdoneのemit時にresを含んでいなかったのを修正
* Update packages/frontend/src/scripts/clone.ts
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
* refactor: 不要な返り値の型を削除
* refactor: 不要なnullチェックを削除
* update: misskey-js-autogen
* update: clone.ts
* refactor
* Update MkNotification.vue
* Update MkNotification.vue
* ✌️
* Update MkNotification.vue
* Update MkNotification.vue
* Update MkNotification.vue
* Update MkNotifications.vue
* Update MkUserSetupDialog.Profile.vue
* Update MkUserCardMini.vue
* ✌️
* Update MkMenu.vue
---------
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
229 lines
5.3 KiB
Vue
229 lines
5.3 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<button
|
|
ref="buttonEl"
|
|
v-ripple="canToggle"
|
|
class="_button"
|
|
:class="[$style.root, { [$style.reacted]: note.myReaction == reaction, [$style.canToggle]: canToggle, [$style.small]: defaultStore.state.reactionsDisplaySize === 'small', [$style.large]: defaultStore.state.reactionsDisplaySize === 'large' }]"
|
|
@click="toggleReaction()"
|
|
@contextmenu.prevent.stop="menu"
|
|
>
|
|
<MkReactionIcon :class="defaultStore.state.limitWidthOfReaction ? $style.limitWidth : ''" :reaction="reaction" :emojiUrl="note.reactionEmojis[reaction.substring(1, reaction.length - 1)]"/>
|
|
<span :class="$style.count">{{ count }}</span>
|
|
</button>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, inject, onMounted, shallowRef, watch } from 'vue';
|
|
import * as Misskey from 'misskey-js';
|
|
import MkCustomEmojiDetailedDialog from './MkCustomEmojiDetailedDialog.vue';
|
|
import XDetails from '@/components/MkReactionsViewer.details.vue';
|
|
import MkReactionIcon from '@/components/MkReactionIcon.vue';
|
|
import * as os from '@/os.js';
|
|
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
|
|
import { useTooltip } from '@/scripts/use-tooltip.js';
|
|
import { $i } from '@/account.js';
|
|
import MkReactionEffect from '@/components/MkReactionEffect.vue';
|
|
import { claimAchievement } from '@/scripts/achievements.js';
|
|
import { defaultStore } from '@/store.js';
|
|
import { i18n } from '@/i18n.js';
|
|
import * as sound from '@/scripts/sound.js';
|
|
|
|
const props = defineProps<{
|
|
reaction: string;
|
|
count: number;
|
|
isInitial: boolean;
|
|
note: Misskey.entities.Note;
|
|
}>();
|
|
|
|
const mock = inject<boolean>('mock', false);
|
|
|
|
const emit = defineEmits<{
|
|
(ev: 'reactionToggled', emoji: string, newCount: number): void;
|
|
}>();
|
|
|
|
const buttonEl = shallowRef<HTMLElement>();
|
|
|
|
const canToggle = computed(() => !props.reaction.match(/@\w/) && $i);
|
|
|
|
async function toggleReaction() {
|
|
if (!canToggle.value) return;
|
|
|
|
// TODO: その絵文字を使う権限があるかどうか確認
|
|
|
|
const oldReaction = props.note.myReaction;
|
|
if (oldReaction) {
|
|
const confirm = await os.confirm({
|
|
type: 'warning',
|
|
text: oldReaction !== props.reaction ? i18n.ts.changeReactionConfirm : i18n.ts.cancelReactionConfirm,
|
|
});
|
|
if (confirm.canceled) return;
|
|
|
|
if (oldReaction !== props.reaction) {
|
|
sound.playMisskeySfx('reaction');
|
|
}
|
|
|
|
if (mock) {
|
|
emit('reactionToggled', props.reaction, (props.count - 1));
|
|
return;
|
|
}
|
|
|
|
misskeyApi('notes/reactions/delete', {
|
|
noteId: props.note.id,
|
|
}).then(() => {
|
|
if (oldReaction !== props.reaction) {
|
|
misskeyApi('notes/reactions/create', {
|
|
noteId: props.note.id,
|
|
reaction: props.reaction,
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
sound.playMisskeySfx('reaction');
|
|
|
|
if (mock) {
|
|
emit('reactionToggled', props.reaction, (props.count + 1));
|
|
return;
|
|
}
|
|
|
|
misskeyApi('notes/reactions/create', {
|
|
noteId: props.note.id,
|
|
reaction: props.reaction,
|
|
});
|
|
if (props.note.text && props.note.text.length > 100 && (Date.now() - new Date(props.note.createdAt).getTime() < 1000 * 3)) {
|
|
claimAchievement('reactWithoutRead');
|
|
}
|
|
}
|
|
}
|
|
|
|
async function menu(ev) {
|
|
if (!canToggle.value) return;
|
|
if (!props.reaction.includes(':')) return;
|
|
os.popupMenu([{
|
|
text: i18n.ts.info,
|
|
icon: 'ti ti-info-circle',
|
|
action: async () => {
|
|
os.popup(MkCustomEmojiDetailedDialog, {
|
|
emoji: await misskeyApiGet('emoji', {
|
|
name: props.reaction.replace(/:/g, '').replace(/@\./, ''),
|
|
}),
|
|
});
|
|
},
|
|
}], ev.currentTarget ?? ev.target);
|
|
}
|
|
|
|
function anime() {
|
|
if (document.hidden || !defaultStore.state.animation || buttonEl.value == null) return;
|
|
|
|
const rect = buttonEl.value.getBoundingClientRect();
|
|
const x = rect.left + 16;
|
|
const y = rect.top + (buttonEl.value.offsetHeight / 2);
|
|
os.popup(MkReactionEffect, { reaction: props.reaction, x, y }, {}, 'end');
|
|
}
|
|
|
|
watch(() => props.count, (newCount, oldCount) => {
|
|
if (oldCount < newCount) anime();
|
|
});
|
|
|
|
onMounted(() => {
|
|
if (!props.isInitial) anime();
|
|
});
|
|
|
|
if (!mock) {
|
|
useTooltip(buttonEl, async (showing) => {
|
|
const reactions = await misskeyApiGet('notes/reactions', {
|
|
noteId: props.note.id,
|
|
type: props.reaction,
|
|
limit: 10,
|
|
_cacheKey_: props.count,
|
|
});
|
|
|
|
const users = reactions.map(x => x.user);
|
|
|
|
os.popup(XDetails, {
|
|
showing,
|
|
reaction: props.reaction,
|
|
users,
|
|
count: props.count,
|
|
targetElement: buttonEl.value,
|
|
}, {}, 'closed');
|
|
}, 100);
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.root {
|
|
display: inline-flex;
|
|
height: 42px;
|
|
margin: 2px;
|
|
padding: 0 6px;
|
|
font-size: 1.5em;
|
|
border-radius: 6px;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
&.canToggle {
|
|
background: var(--buttonBg);
|
|
|
|
&:hover {
|
|
background: rgba(0, 0, 0, 0.1);
|
|
}
|
|
}
|
|
|
|
&:not(.canToggle) {
|
|
cursor: default;
|
|
}
|
|
|
|
&.small {
|
|
height: 32px;
|
|
font-size: 1em;
|
|
border-radius: 4px;
|
|
|
|
> .count {
|
|
font-size: 0.9em;
|
|
line-height: 32px;
|
|
}
|
|
}
|
|
|
|
&.large {
|
|
height: 52px;
|
|
font-size: 2em;
|
|
border-radius: 8px;
|
|
|
|
> .count {
|
|
font-size: 0.6em;
|
|
line-height: 52px;
|
|
}
|
|
}
|
|
|
|
&.reacted, &.reacted:hover {
|
|
background: var(--accentedBg);
|
|
color: var(--accent);
|
|
box-shadow: 0 0 0 1px var(--accent) inset;
|
|
|
|
> .count {
|
|
color: var(--accent);
|
|
}
|
|
|
|
> .icon {
|
|
filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
|
|
}
|
|
}
|
|
}
|
|
|
|
.limitWidth {
|
|
max-width: 70px;
|
|
object-fit: contain;
|
|
}
|
|
|
|
.count {
|
|
font-size: 0.7em;
|
|
line-height: 42px;
|
|
margin: 0 0 0 4px;
|
|
}
|
|
</style>
|