1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-26 21:54:16 +02:00

refactor(frontend): refactor deck events (#17290)

This commit is contained in:
かっこかり
2026-04-08 14:45:30 +09:00
committed by GitHub
parent 5cb3a91b15
commit 92e0e8edf7
3 changed files with 15 additions and 11 deletions

View File

@@ -5,6 +5,7 @@
import { notificationTypes } from 'misskey-js'; import { notificationTypes } from 'misskey-js';
import { ref } from 'vue'; import { ref } from 'vue';
import { EventEmitter } from 'eventemitter3';
import { i18n } from './i18n.js'; import { i18n } from './i18n.js';
import type { BasicTimelineType } from '@/timelines.js'; import type { BasicTimelineType } from '@/timelines.js';
import type { SoundStore } from '@/preferences/def.js'; import type { SoundStore } from '@/preferences/def.js';
@@ -14,6 +15,13 @@ import { deepClone } from '@/utility/clone.js';
import { prefer } from '@/preferences.js'; import { prefer } from '@/preferences.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
type DeckEvents = {
'column.dragStart': () => void;
'column.dragEnd': () => void;
};
export const deckGlobalEvents = new EventEmitter<DeckEvents>();
export type DeckProfile = { export type DeckProfile = {
name: string; name: string;
id: string; id: string;

View File

@@ -6,7 +6,6 @@
// TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する // TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する
import { markRaw, ref, defineAsyncComponent, nextTick } from 'vue'; import { markRaw, ref, defineAsyncComponent, nextTick } from 'vue';
import { EventEmitter } from 'eventemitter3';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import type { Component, MaybeRef } from 'vue'; import type { Component, MaybeRef } from 'vue';
import type { ComponentEmit, ComponentProps as CP } from 'vue-component-type-helpers'; import type { ComponentEmit, ComponentProps as CP } from 'vue-component-type-helpers';
@@ -729,8 +728,6 @@ export async function post(props: PostFormProps = {}): Promise<void> {
}); });
} }
export const deckGlobalEvents = new EventEmitter();
/* /*
export function checkExistence(fileData: ArrayBuffer): Promise<any> { export function checkExistence(fileData: ArrayBuffer): Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@@ -46,11 +46,10 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onBeforeUnmount, onMounted, provide, watch, useTemplateRef, ref, computed } from 'vue'; import { onBeforeUnmount, onMounted, provide, watch, useTemplateRef, ref, computed } from 'vue';
import type { Column } from '@/deck.js'; import type { Column } from '@/deck.js';
import type { MenuItem } from '@/types/menu.js'; import type { MenuItem } from '@/types/menu.js';
import { updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn } from '@/deck.js'; import { deckGlobalEvents, updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn } from '@/deck.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { prefer } from '@/preferences.js'; import { prefer } from '@/preferences.js';
import { DI } from '@/di.js';
import { checkDragDataType, getDragData, setDragData } from '@/drag-and-drop.js'; import { checkDragDataType, getDragData, setDragData } from '@/drag-and-drop.js';
provide('shouldHeaderThin', true); provide('shouldHeaderThin', true);
@@ -79,7 +78,7 @@ const emit = defineEmits<{
const body = useTemplateRef('body'); const body = useTemplateRef('body');
const dragging = ref(false); const dragging = ref(false);
watch(dragging, v => os.deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd')); watch(dragging, v => deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd'));
const draghover = ref(false); const draghover = ref(false);
const dropready = ref(false); const dropready = ref(false);
@@ -88,13 +87,13 @@ const isMainColumn = computed(() => props.column.type === 'main');
const active = computed(() => props.column.active !== false); const active = computed(() => props.column.active !== false);
onMounted(() => { onMounted(() => {
os.deckGlobalEvents.on('column.dragStart', onOtherDragStart); deckGlobalEvents.on('column.dragStart', onOtherDragStart);
os.deckGlobalEvents.on('column.dragEnd', onOtherDragEnd); deckGlobalEvents.on('column.dragEnd', onOtherDragEnd);
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
os.deckGlobalEvents.off('column.dragStart', onOtherDragStart); deckGlobalEvents.off('column.dragStart', onOtherDragStart);
os.deckGlobalEvents.off('column.dragEnd', onOtherDragEnd); deckGlobalEvents.off('column.dragEnd', onOtherDragEnd);
}); });
function onOtherDragStart() { function onOtherDragStart() {
@@ -306,7 +305,7 @@ function onDragleave() {
function onDrop(ev: DragEvent) { function onDrop(ev: DragEvent) {
draghover.value = false; draghover.value = false;
os.deckGlobalEvents.emit('column.dragEnd'); deckGlobalEvents.emit('column.dragEnd');
const id = getDragData(ev, 'deckColumn'); const id = getDragData(ev, 'deckColumn');
if (id != null) { if (id != null) {