fix liked pages endpoint
This commit is contained in:
parent
622a6cf0cd
commit
a11fd6971d
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "calckey",
|
||||
"version": "12.119.0-calc.19-b15",
|
||||
"version": "12.119.0-calc.19-b16",
|
||||
"codename": "aqua",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { db } from '@/db/postgre.js';
|
||||
import { PageLike } from '@/models/entities/page-like.js';
|
||||
import type { User } from '@/models/entities/user.js';
|
||||
import { Pages } from '../index.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
|
||||
export const PageLikeRepository = db.getRepository(PageLike).extend({
|
||||
async pack(
|
||||
src: PageLike['id'] | PageLike,
|
||||
me?: { id: User['id'] } | null | undefined
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
) {
|
||||
const like = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
|
||||
|
||||
|
@ -17,8 +17,8 @@ export const PageLikeRepository = db.getRepository(PageLike).extend({
|
|||
},
|
||||
|
||||
packMany(
|
||||
likes: any[],
|
||||
me: { id: User['id'] }
|
||||
likes: PageLike[],
|
||||
me: { id: User['id'] },
|
||||
) {
|
||||
return Promise.all(likes.map(x => this.pack(x, me)));
|
||||
},
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { db } from '@/db/postgre.js';
|
||||
import { Page } from '@/models/entities/page.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
import type { Packed } from '@/misc/schema.js';
|
||||
import { awaitAll } from '@/prelude/await-all.js';
|
||||
import { DriveFile } from '@/models/entities/drive-file.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import type { DriveFile } from '@/models/entities/drive-file.js';
|
||||
import type { User } from '@/models/entities/user.js';
|
||||
import { Users, DriveFiles, PageLikes } from '../index.js';
|
||||
|
||||
export const PageRepository = db.getRepository(Page).extend({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import define from '../../define.js';
|
||||
import { PageLikes } from '@/models/index.js';
|
||||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
|
||||
export const meta = {
|
||||
|
@ -26,7 +26,7 @@ export const meta = {
|
|||
ref: 'Page',
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
@ -43,7 +43,7 @@ export const paramDef = {
|
|||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const query = makePaginationQuery(PageLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId)
|
||||
.andWhere(`like.userId = :meId`, { meId: user.id })
|
||||
.andWhere('like.userId = :meId', { meId: user.id })
|
||||
.leftJoinAndSelect('like.page', 'page');
|
||||
|
||||
const likes = await query
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import define from '../../define.js';
|
||||
import { Pages } from '@/models/index.js';
|
||||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
|
||||
export const meta = {
|
||||
|
@ -33,7 +33,7 @@ export const paramDef = {
|
|||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId)
|
||||
.andWhere(`page.userId = :meId`, { meId: user.id });
|
||||
.andWhere('page.userId = :meId', { meId: user.id });
|
||||
|
||||
const pages = await query
|
||||
.take(ps.limit)
|
||||
|
|
|
@ -60,7 +60,7 @@ watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
|
|||
|
||||
const featuredPagesPagination = {
|
||||
endpoint: 'pages/featured' as const,
|
||||
noPaging: true,
|
||||
limit: 10,
|
||||
};
|
||||
const myPagesPagination = {
|
||||
endpoint: 'i/pages' as const,
|
||||
|
|
Loading…
Reference in New Issue