Merge branch 'develop' into account_migration

This commit is contained in:
Kainoa Kanter 2022-12-12 01:51:17 +00:00
commit ed02d089ed
10 changed files with 50 additions and 48 deletions

View File

@ -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)));
},

View File

@ -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({

View File

@ -1,5 +1,5 @@
import define from '../../../define.js';
import { GalleryPosts } 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(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId)
.andWhere(`post.userId = :meId`, { meId: user.id });
.andWhere('post.userId = :meId', { meId: user.id });
const posts = await query
.take(ps.limit)

View File

@ -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

View File

@ -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)

View File

@ -7,7 +7,7 @@
</header>
<p v-if="page.summary" :title="page.summary">{{ page.summary.length > 85 ? page.summary.slice(0, 85) + '…' : page.summary }}</p>
<footer>
<img class="icon" :src="page.user.avatarUrl"/>
<img class="icon" :src="page.user.avatarUrl" aria-label="none"/>
<p>{{ userName(page.user) }}</p>
</footer>
</article>
@ -17,7 +17,6 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { userName } from '@/filters/user';
import * as os from '@/os';
export default defineComponent({
props: {

View File

@ -49,7 +49,7 @@
</template>
<script lang="ts" setup>
import { computed, defineComponent, watch } from 'vue';
import { computed, defineComponent, watch, onMounted } from 'vue';
import { Virtual } from 'swiper';
import { Swiper, SwiperSlide } from 'swiper/vue';
import MkFolder from '@/components/MkFolder.vue';
@ -137,6 +137,10 @@ function onSlideChange() {
function syncSlide(index) {
swiperRef.slideTo(index);
}
onMounted(() => {
syncSlide(tabs.indexOf(swiperRef.activeIndex));
});
</script>
<style lang="scss" scoped>

View File

@ -120,12 +120,7 @@ function like() {
}
async function unlike() {
const confirm = await os.confirm({
type: 'warning',
text: i18n.ts.unlikeConfirm,
});
if (confirm.canceled) return;
os.apiWithDialog('gallery/posts/unlike', {
os.api('gallery/posts/unlike', {
postId: props.postId,
}).then(() => {
post.isLiked = false;

View File

@ -153,12 +153,7 @@ function like() {
}
async function unlike() {
const confirm = await os.confirm({
type: 'warning',
text: i18n.ts.unlikeConfirm,
});
if (confirm.canceled) return;
os.apiWithDialog('pages/unlike', {
os.api('pages/unlike', {
pageId: page.id,
}).then(() => {
page.isLiked = false;

View File

@ -18,17 +18,19 @@
</div>
</swiper-slide>
<swiper-slide>
<div class="rknalgpo my">
<MkButton class="new" @click="create()"><i class="ph-plus-bold ph-lg"></i></MkButton>
<MkPagination v-slot="{items}" :pagination="myPagesPagination">
<MkPagePreview v-for="page in items" :key="page.id" class="ckltabjg" :page="page"/>
<div class="rknalgpo liked">
<MkPagination v-slot="{items}" :pagination="likedPagesPagination">
<MkPagePreview v-for="like in items" :key="like.page.id" class="ckltabjg" :page="like.page"/>
</MkPagination>
</div>
</swiper-slide>
<swiper-slide>
<div class="rknalgpo">
<MkPagination v-slot="{items}" :pagination="likedPagesPagination">
<MkPagePreview v-for="like in items" :key="like.page.id" class="ckltabjg" :page="like.page"/>
<div class="rknalgpo my">
<div class="buttoncontainer">
<MkButton class="new primary" @click="create()"><i class="ph-plus-bold ph-lg"></i> {{ i18n.ts._pages.newPage }}</MkButton>
</div>
<MkPagination v-slot="{items}" :pagination="myPagesPagination">
<MkPagePreview v-for="page in items" :key="page.id" class="ckltabjg" :page="page"/>
</MkPagination>
</div>
</swiper-slide>
@ -55,20 +57,20 @@ import 'swiper/scss/virtual';
const router = useRouter();
let tab = $ref('featured');
const tabs = ['featured', 'my', 'liked'];
const tabs = ['featured', 'liked', 'my'];
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
const featuredPagesPagination = {
endpoint: 'pages/featured' as const,
noPaging: true,
};
const myPagesPagination = {
endpoint: 'i/pages' as const,
limit: 5,
limit: 10,
};
const likedPagesPagination = {
endpoint: 'i/page-likes' as const,
limit: 5,
limit: 10,
};
const myPagesPagination = {
endpoint: 'i/pages' as const,
limit: 10,
};
function create() {
@ -85,19 +87,19 @@ const headerTabs = $computed(() => [{
key: 'featured',
title: i18n.ts._pages.featured,
icon: 'ph-fire-simple-bold ph-lg',
}, {
key: 'my',
title: i18n.ts._pages.my,
icon: 'ph-crown-simple-bold ph-lg',
}, {
key: 'liked',
title: i18n.ts._pages.liked,
icon: 'ph-heart-bold ph-lg',
}, {
key: 'my',
title: i18n.ts._pages.my,
icon: 'ph-crown-simple-bold ph-lg',
}]);
definePageMetadata(computed(() => ({
title: i18n.ts.pages,
icon: 'ph-sticker-bold ph-lg',
icon: 'ph-file-text-bold ph-lg',
})));
let swiperRef = null;
@ -122,6 +124,13 @@ onMounted(() => {
<style lang="scss" scoped>
.rknalgpo {
> .buttoncontainer {
display: grid;
justify-content: center;
margin-bottom: 1rem;
}
&.my .ckltabjg:first-child {
margin-top: 16px;
}