Modify backend for Calckey

This commit is contained in:
naskya 2023-05-07 09:13:37 +09:00
parent baef1b8ca9
commit 27d1d96c9d
No known key found for this signature in database
GPG Key ID: 164DFF24E2D40139
2 changed files with 36 additions and 48 deletions

View File

@ -1,9 +1,8 @@
import { Inject, Injectable } from "@nestjs/common"; import define from "../../define.js";
import { Brackets } from "typeorm"; import { Brackets } from "typeorm";
import { Endpoint } from "@/server/api/endpoint-base.js"; import { Endpoint } from "@/server/api/endpoint-base.js";
import { QueryService } from "@/core/QueryService.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js";
import type { ChannelsRepository } from "@/models/index.js"; import { Channels } from "@/models/index.js";
import { ChannelEntityService } from "@/core/entities/ChannelEntityService.js";
import { DI } from "@/di-symbols.js"; import { DI } from "@/di-symbols.js";
import { sqlLikeEscape } from "@/misc/sql-like-escape.js"; import { sqlLikeEscape } from "@/misc/sql-like-escape.js";
@ -41,19 +40,9 @@ export const paramDef = {
required: ["query"], required: ["query"],
} as const; } as const;
// eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, me) => {
@Injectable() const query = makePaginationQuery(
export default class extends Endpoint<typeof meta, typeof paramDef> { Channels.createQueryBuilder("channel"),
constructor(
@Inject(DI.channelsRepository)
private channelsRepository: ChannelsRepository,
private channelEntityService: ChannelEntityService,
private queryService: QueryService,
) {
super(meta, paramDef, async (ps, me) => {
const query = this.queryService.makePaginationQuery(
this.channelsRepository.createQueryBuilder("channel"),
ps.sinceId, ps.sinceId,
ps.untilId, ps.untilId,
); );
@ -77,8 +66,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const channels = await query.take(ps.limit).getMany(); const channels = await query.take(ps.limit).getMany();
return await Promise.all( return await Promise.all(
channels.map((x) => this.channelEntityService.pack(x, me)), channels.map((x) => Channels.pack(x, me)),
); );
}); });
}
}

View File

@ -22,7 +22,6 @@
> >
<swiper-slide> <swiper-slide>
<div class="_content grwlizim search"> <div class="_content grwlizim search">
<div class="gaps">
<MkInput <MkInput
v-model="searchQuery" v-model="searchQuery"
:large="true" :large="true"
@ -30,12 +29,15 @@
type="search" type="search"
> >
<template #prefix <template #prefix
><i class="ph-search ph-bold ph-lg"></i ><i
class="ph-magnifying-glass ph-bold ph-lg"
></i
></template> ></template>
</MkInput> </MkInput>
<MkRadios <MkRadios
v-model="searchType" v-model="searchType"
@update:model-value="search()" @update:model-value="search()"
class="_gap"
> >
<option value="nameAndDescription"> <option value="nameAndDescription">
{{ i18n.ts._channel.nameAndDescription }} {{ i18n.ts._channel.nameAndDescription }}
@ -50,9 +52,9 @@
gradate gradate
rounded rounded
@click="search" @click="search"
class="_gap"
>{{ i18n.ts.search }}</MkButton >{{ i18n.ts.search }}</MkButton
> >
</div>
<MkFoldableSection v-if="channelPagination"> <MkFoldableSection v-if="channelPagination">
<template #header>{{ <template #header>{{
i18n.ts.searchResult i18n.ts.searchResult
@ -124,10 +126,10 @@ import { Swiper, SwiperSlide } from "swiper/vue";
import MkChannelPreview from "@/components/MkChannelPreview.vue"; import MkChannelPreview from "@/components/MkChannelPreview.vue";
import MkChannelList from "@/components/MkChannelList.vue"; import MkChannelList from "@/components/MkChannelList.vue";
import MkPagination from "@/components/MkPagination.vue"; import MkPagination from "@/components/MkPagination.vue";
import MkInput from "@/components/MkInput.vue"; import MkInput from "@/components/form/input.vue";
import MkRadios from "@/components/MkRadios.vue"; import MkRadios from "@/components/form/radios.vue";
import MkButton from "@/components/MkButton.vue"; import MkButton from "@/components/MkButton.vue";
import MkFoldableSection from "@/components/MkFoldableSection.vue"; import MkFolder from "@/components/MkFolder.vue";
import { useRouter } from "@/router"; import { useRouter } from "@/router";
import { definePageMetadata } from "@/scripts/page-metadata"; import { definePageMetadata } from "@/scripts/page-metadata";
import { deviceKind } from "@/scripts/device-kind"; import { deviceKind } from "@/scripts/device-kind";
@ -147,7 +149,6 @@ const props = defineProps<{
type?: string; type?: string;
}>(); }>();
let key = $ref(""); let key = $ref("");
let tab = $ref("search");
let searchQuery = $ref(""); let searchQuery = $ref("");
let searchType = $ref("nameAndDescription"); let searchType = $ref("nameAndDescription");
let channelPagination = $ref(); let channelPagination = $ref();
@ -201,7 +202,7 @@ const headerTabs = $computed(() => [
{ {
key: "search", key: "search",
title: i18n.ts.search, title: i18n.ts.search,
icon: "ph-search ph-bold ph-lg", icon: "ph-magnifying-glass ph-bold ph-lg",
}, },
{ {
key: "featured", key: "featured",