refactor: ♻️ unessicary function

This commit is contained in:
ThatOneCalculator 2023-09-20 22:53:00 -07:00
parent bbb2396d89
commit d9274de0a7
No known key found for this signature in database
GPG key ID: 8703CACD01000000
3 changed files with 4 additions and 9 deletions

View file

@ -90,7 +90,3 @@ export function decodeReaction(str: string): DecodedReaction {
host: undefined,
};
}
export function convertToDecoded(reaction: string): string {
return decodeReaction(reaction).reaction;
}

View file

@ -2,7 +2,7 @@ import { db } from "@/db/postgre.js";
import { NoteReaction } from "@/models/entities/note-reaction.js";
import { Notes, Users } from "../index.js";
import type { Packed } from "@/misc/schema.js";
import { convertToDecoded } from "@/misc/reaction-lib.js";
import { decodeReaction } from "@/misc/reaction-lib.js";
import type { User } from "@/models/entities/user.js";
export const NoteReactionRepository = db.getRepository(NoteReaction).extend({
@ -27,7 +27,7 @@ export const NoteReactionRepository = db.getRepository(NoteReaction).extend({
id: reaction.id,
createdAt: reaction.createdAt.toISOString(),
user: await Users.pack(reaction.user ?? reaction.userId, me),
type: convertToDecoded(reaction.reaction),
type: decodeReaction(reaction.reaction).reaction,
...(opts.withNote
? {
// may throw error

View file

@ -15,7 +15,6 @@ import type { Packed } from "@/misc/schema.js";
import { nyaize } from "@/misc/nyaize.js";
import { awaitAll } from "@/prelude/await-all.js";
import {
convertToDecoded,
convertReactions,
decodeReaction,
} from "@/misc/reaction-lib.js";
@ -77,7 +76,7 @@ async function populateMyReaction(
if (_hint_?.myReactions) {
const reaction = _hint_.myReactions.get(note.id);
if (reaction) {
return convertToDecoded(reaction.reaction);
return decodeReaction(reaction.reaction).reaction;
} else if (reaction === null) {
return undefined;
}
@ -90,7 +89,7 @@ async function populateMyReaction(
});
if (reaction) {
return convertToDecoded(reaction.reaction);
return decodeReaction(reaction.reaction).reaction;
}
return undefined;