Renote button optimization

This commit is contained in:
Natty 2023-04-20 21:16:36 +02:00 committed by ThatOneCalculator
parent 97e69144f6
commit 1773ae14e3
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
2 changed files with 12 additions and 5 deletions

View File

@ -38,6 +38,7 @@ export const paramDef = {
type: "object",
properties: {
noteId: { type: "string", format: "misskey:id" },
userId: { type: "string", format: "misskey:id" },
limit: { type: "integer", minimum: 1, maximum: 100, default: 10 },
sinceId: { type: "string", format: "misskey:id" },
untilId: { type: "string", format: "misskey:id" },
@ -52,13 +53,19 @@ export default define(meta, paramDef, async (ps, user) => {
throw err;
});
const query = makePaginationQuery(
let query = makePaginationQuery(
Notes.createQueryBuilder("note"),
ps.sinceId,
ps.untilId,
)
.andWhere("note.renoteId = :renoteId", { renoteId: note.id })
.innerJoinAndSelect("note.user", "user")
.innerJoinAndSelect("note.user", "user");
if (ps.userId) {
query.andWhere("user.id = :userId", { userId: ps.userId });
}
query
.leftJoinAndSelect("user.avatar", "avatar")
.leftJoinAndSelect("user.banner", "banner")
.leftJoinAndSelect("note.reply", "reply")

View File

@ -69,11 +69,11 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
const renotes = await os.api("notes/renotes", {
noteId: props.note.id,
limit: 11,
userId: $i.id,
limit: 1,
});
const users = renotes.map((x) => x.user.id);
const hasRenotedBefore = users.includes($i.id);
const hasRenotedBefore = renotes.length > 0;
let buttonActions: Array<MenuItem> = [];