This commit is contained in:
syuilo 2023-11-01 15:58:40 +09:00
parent 49411e2ffb
commit 19ca2872a5
3 changed files with 12 additions and 10 deletions

View file

@ -46,7 +46,7 @@ const emit = defineEmits<{
let menuShowing = false;
function detachMedia(id: string) {
if (props.mock) return;
if (mock) return;
if (props.detachMediaFn) {
props.detachMediaFn(id);
@ -56,7 +56,7 @@ function detachMedia(id: string) {
}
function toggleSensitive(file) {
if (props.mock) {
if (mock) {
emit('changeSensitive', file, !file.isSensitive);
return;
}
@ -70,7 +70,7 @@ function toggleSensitive(file) {
}
async function rename(file) {
if (props.mock) return;
if (mock) return;
const { canceled, result } = await os.inputText({
title: i18n.ts.enterFileName,
@ -88,7 +88,7 @@ async function rename(file) {
}
async function describe(file) {
if (props.mock) return;
if (mock) return;
os.popup(defineAsyncComponent(() => import('@/components/MkFileCaptionEditWindow.vue')), {
default: file.comment !== null ? file.comment : '',
@ -107,7 +107,7 @@ async function describe(file) {
}
async function crop(file: Misskey.entities.DriveFile): Promise<void> {
if (props.mock) return;
if (mock) return;
const newFile = await os.cropImage(file, { aspectRatio: NaN });
emit('replaceFile', file, newFile);

View file

@ -59,7 +59,7 @@ async function toggleReaction() {
});
if (confirm.canceled) return;
if (props.mock) {
if (mock) {
emit('reactionToggled', props.reaction, (props.count - 1));
return;
}
@ -75,7 +75,7 @@ async function toggleReaction() {
}
});
} else {
if (props.mock) {
if (mock) {
emit('reactionToggled', props.reaction, (props.count + 1));
return;
}
@ -108,7 +108,7 @@ onMounted(() => {
if (!props.isInitial) anime();
});
if (!props.mock) {
if (!mock) {
useTooltip(buttonEl, async (showing) => {
const reactions = await os.apiGet('notes/reactions', {
noteId: props.note.id,

View file

@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import * as Misskey from 'misskey-js';
import { watch } from 'vue';
import { inject, watch } from 'vue';
import XReaction from '@/components/MkReactionsViewer.reaction.vue';
import { defaultStore } from '@/store.js';
@ -30,6 +30,8 @@ const props = withDefaults(defineProps<{
maxNumber: Infinity,
});
const mock = inject<boolean>('mock', false);
const emit = defineEmits<{
(ev: 'mockUpdateMyReaction', emoji: string, delta: number): void;
}>();
@ -44,7 +46,7 @@ if (props.note.myReaction && !Object.keys(reactions).includes(props.note.myReact
}
function onMockToggleReaction(emoji: string, count: number) {
if (!props.mock) return;
if (!mock) return;
const i = reactions.findIndex((item) => item[0] === emoji);
if (i < 0) return;