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