summaryrefslogtreecommitdiff
path: root/packages/frontend/src/composables/use-note-capture.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/composables/use-note-capture.ts')
-rw-r--r--packages/frontend/src/composables/use-note-capture.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/packages/frontend/src/composables/use-note-capture.ts b/packages/frontend/src/composables/use-note-capture.ts
index 2aeb9074e5..25a9383cd5 100644
--- a/packages/frontend/src/composables/use-note-capture.ts
+++ b/packages/frontend/src/composables/use-note-capture.ts
@@ -7,6 +7,7 @@ import { onUnmounted, reactive } from 'vue';
import * as Misskey from 'misskey-js';
import { EventEmitter } from 'eventemitter3';
import type { Reactive } from 'vue';
+import type { NoteUpdatedEvent } from 'misskey-js/streaming.types.js';
import { useStream } from '@/stream.js';
import { $i } from '@/i.js';
import { store } from '@/store.js';
@@ -15,9 +16,9 @@ import { prefer } from '@/preferences.js';
import { globalEvents } from '@/events.js';
export const noteEvents = new EventEmitter<{
- [ev: `reacted:${string}`]: (ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; }; }) => void;
- [ev: `unreacted:${string}`]: (ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; }; }) => void;
- [ev: `pollVoted:${string}`]: (ctx: { userId: Misskey.entities.User['id']; choice: string; }) => void;
+ [ev: `reacted:${string}`]: (ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; } | null; }) => void;
+ [ev: `unreacted:${string}`]: (ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; } | null; }) => void;
+ [ev: `pollVoted:${string}`]: (ctx: { userId: Misskey.entities.User['id']; choice: number; }) => void;
}>();
const fetchEvent = new EventEmitter<{
@@ -117,7 +118,7 @@ function realtimeSubscribe(props: {
const note = props.note;
const connection = useStream();
- function onStreamNoteUpdated(noteData): void {
+ function onStreamNoteUpdated(noteData: NoteUpdatedEvent): void {
const { type, id, body } = noteData;
if (id !== note.id) return;
@@ -136,7 +137,6 @@ function realtimeSubscribe(props: {
noteEvents.emit(`unreacted:${id}`, {
userId: body.userId,
reaction: body.reaction,
- emoji: body.emoji,
});
break;
}
@@ -194,9 +194,9 @@ export function useNoteCapture(props: {
parentNote: Misskey.entities.Note | null;
mock?: boolean;
}): {
- $note: Reactive<ReactiveNoteData>;
- subscribe: () => void;
- } {
+ $note: Reactive<ReactiveNoteData>;
+ subscribe: () => void;
+} {
const { note, parentNote, mock } = props;
const $note = reactive<ReactiveNoteData>({
@@ -224,7 +224,7 @@ export function useNoteCapture(props: {
const reactionUserMap = new Map<Misskey.entities.User['id'], string | typeof noReaction>();
let latestPollVotedKey: string | null = null;
- function onReacted(ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; }; }): void {
+ function onReacted(ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; } | null; }): void {
let normalizedName = ctx.reaction.replace(/^:(\w+):$/, ':$1@.:');
normalizedName = normalizedName.match('\u200d') ? normalizedName : normalizedName.replace(/\ufe0f/g, '');
if (reactionUserMap.has(ctx.userId) && reactionUserMap.get(ctx.userId) === normalizedName) return;
@@ -244,7 +244,7 @@ export function useNoteCapture(props: {
}
}
- function onUnreacted(ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; }; }): void {
+ function onUnreacted(ctx: { userId: Misskey.entities.User['id']; reaction: string; emoji?: { name: string; url: string; } | null; }): void {
let normalizedName = ctx.reaction.replace(/^:(\w+):$/, ':$1@.:');
normalizedName = normalizedName.match('\u200d') ? normalizedName : normalizedName.replace(/\ufe0f/g, '');
@@ -263,7 +263,7 @@ export function useNoteCapture(props: {
}
}
- function onPollVoted(ctx: { userId: Misskey.entities.User['id']; choice: string; }): void {
+ function onPollVoted(ctx: { userId: Misskey.entities.User['id']; choice: number; }): void {
const newPollVotedKey = `${ctx.userId}:${ctx.choice}`;
if (newPollVotedKey === latestPollVotedKey) return;
latestPollVotedKey = newPollVotedKey;