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

View file

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

View file

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