wip: clip

This commit is contained in:
syuilo 2020-11-15 12:47:54 +09:00
parent f0d0a1546a
commit cac99ebdd4
2 changed files with 25 additions and 2 deletions

View File

@ -4,6 +4,9 @@
<div class="description" v-if="clip.description"> <div class="description" v-if="clip.description">
<Mfm :text="clip.description" :is-note="false" :i="$store.state.i"/> <Mfm :text="clip.description" :is-note="false" :i="$store.state.i"/>
</div> </div>
<div class="user">
<MkAvatar :user="clip.user" class="avatar"/> <MkUserName :user="clip.user" :nowrap="false"/>
</div>
</div> </div>
<XNotes class="_content _vMargin" :pagination="pagination" :detail="true"/> <XNotes class="_content _vMargin" :pagination="pagination" :detail="true"/>
@ -135,5 +138,17 @@ export default defineComponent({
> .description { > .description {
padding: 16px; padding: 16px;
} }
> .user {
$height: 32px;
padding: 16px;
border-top: solid 1px var(--divider);
line-height: $height;
> .avatar {
width: $height;
height: $height;
}
}
} }
</style> </style>

View File

@ -2,6 +2,8 @@ import { EntityRepository, Repository } from 'typeorm';
import { Clip } from '../entities/clip'; import { Clip } from '../entities/clip';
import { ensure } from '../../prelude/ensure'; import { ensure } from '../../prelude/ensure';
import { SchemaType } from '../../misc/schema'; import { SchemaType } from '../../misc/schema';
import { Users } from '..';
import { awaitAll } from '../../prelude/await-all';
export type PackedClip = SchemaType<typeof packedClipSchema>; export type PackedClip = SchemaType<typeof packedClipSchema>;
@ -12,14 +14,15 @@ export class ClipRepository extends Repository<Clip> {
): Promise<PackedClip> { ): Promise<PackedClip> {
const clip = typeof src === 'object' ? src : await this.findOne(src).then(ensure); const clip = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
return { return await awaitAll({
id: clip.id, id: clip.id,
createdAt: clip.createdAt.toISOString(), createdAt: clip.createdAt.toISOString(),
userId: clip.userId, userId: clip.userId,
user: Users.pack(clip.user || clip.userId),
name: clip.name, name: clip.name,
description: clip.description, description: clip.description,
isPublic: clip.isPublic, isPublic: clip.isPublic,
}; });
} }
} }
@ -45,6 +48,11 @@ export const packedClipSchema = {
optional: false as const, nullable: false as const, optional: false as const, nullable: false as const,
format: 'id', format: 'id',
}, },
user: {
type: 'object' as const,
ref: 'User',
optional: false as const, nullable: false as const,
},
name: { name: {
type: 'string' as const, type: 'string' as const,
optional: false as const, nullable: false as const, optional: false as const, nullable: false as const,