Renote button optimization
This commit is contained in:
parent
97e69144f6
commit
1773ae14e3
2 changed files with 12 additions and 5 deletions
|
@ -38,6 +38,7 @@ export const paramDef = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
noteId: { type: "string", format: "misskey:id" },
|
noteId: { type: "string", format: "misskey:id" },
|
||||||
|
userId: { type: "string", format: "misskey:id" },
|
||||||
limit: { type: "integer", minimum: 1, maximum: 100, default: 10 },
|
limit: { type: "integer", minimum: 1, maximum: 100, default: 10 },
|
||||||
sinceId: { type: "string", format: "misskey:id" },
|
sinceId: { type: "string", format: "misskey:id" },
|
||||||
untilId: { 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;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
const query = makePaginationQuery(
|
let query = makePaginationQuery(
|
||||||
Notes.createQueryBuilder("note"),
|
Notes.createQueryBuilder("note"),
|
||||||
ps.sinceId,
|
ps.sinceId,
|
||||||
ps.untilId,
|
ps.untilId,
|
||||||
)
|
)
|
||||||
.andWhere("note.renoteId = :renoteId", { renoteId: note.id })
|
.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.avatar", "avatar")
|
||||||
.leftJoinAndSelect("user.banner", "banner")
|
.leftJoinAndSelect("user.banner", "banner")
|
||||||
.leftJoinAndSelect("note.reply", "reply")
|
.leftJoinAndSelect("note.reply", "reply")
|
||||||
|
|
|
@ -69,11 +69,11 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
|
||||||
|
|
||||||
const renotes = await os.api("notes/renotes", {
|
const renotes = await os.api("notes/renotes", {
|
||||||
noteId: props.note.id,
|
noteId: props.note.id,
|
||||||
limit: 11,
|
userId: $i.id,
|
||||||
|
limit: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
const users = renotes.map((x) => x.user.id);
|
const hasRenotedBefore = renotes.length > 0;
|
||||||
const hasRenotedBefore = users.includes($i.id);
|
|
||||||
|
|
||||||
let buttonActions: Array<MenuItem> = [];
|
let buttonActions: Array<MenuItem> = [];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue