turn task into a function

This commit is contained in:
piuvas 2024-12-25 16:41:40 -03:00
parent 94c3a71e49
commit 64abef8be9
No known key found for this signature in database
GPG key ID: 82743F52454C621D
6 changed files with 50 additions and 72 deletions

View file

@ -10,6 +10,7 @@ import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
import type { Packed } from '@/misc/json-schema.js';
import type { JsonObject, JsonValue } from '@/misc/json-value.js';
import type Connection from './Connection.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
/**
* Stream channel
@ -101,6 +102,14 @@ export default abstract class Channel {
public dispose?(): void;
public onMessage?(type: string, body: JsonValue): void;
public async assignMyReaction(note: Packed<'Note'>, noteEntityService: NoteEntityService) {
if (this.user === undefined) { return; }
if (Object.keys(note.reactions).length > 0) {
const myReaction = await noteEntityService.populateMyReaction(note, this.user.id);
note.myReaction = myReaction;
}
}
}
export type MiChannelService<T extends boolean> = {