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

@ -65,25 +65,19 @@ class BubbleTimelineChannel extends Channel {
if (this.isNoteMutedOrBlocked(note)) return;
const reactionsToFetch = [];
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
note.renote.myReaction = myRenoteReaction;
}
if (note.renote && note.renote.reply) {
if (Object.keys(note.renote.reply.reactions).length > 0) {
const myReplyReaction = await this.noteEntityService.populateMyReaction(note.renote.reply, this.user.id);
note.renote.reply.myReaction = myReplyReaction;
if (note.renote) {
reactionsToFetch.push(this.assignMyReaction(note.renote, this.noteEntityService));
if (note.renote.reply) {
reactionsToFetch.push(this.assignMyReaction(note.renote.reply, this.noteEntityService));
}
}
} else if (this.user && note.reply) {
reactionsToFetch.push(this.assignMyReaction(note.reply, this.noteEntityService));
}
if (this.user && note.reply) {
if (Object.keys(note.reply.reactions).length > 0) {
const myReplyReaction = await this.noteEntityService.populateMyReaction(note.reply, this.user.id);
note.reply.myReaction = myReplyReaction;
}
}
await Promise.all(reactionsToFetch);
this.connection.cacheNote(note);