format
This commit is contained in:
parent
54f6876c9c
commit
8a2135ba28
8 changed files with 141 additions and 89 deletions
|
@ -16,7 +16,7 @@ export default async function renderNote(
|
||||||
dive = true,
|
dive = true,
|
||||||
isTalk = false,
|
isTalk = false,
|
||||||
): Promise<Record<string, unknown>> {
|
): Promise<Record<string, unknown>> {
|
||||||
note.visibility = note.visibility === "hidden" ? "home" : note.visibility;
|
note.visibility = note.visibility === "hidden" ? "home" : note.visibility;
|
||||||
const getPromisedFiles = async (ids: string[]) => {
|
const getPromisedFiles = async (ids: string[]) => {
|
||||||
if (!ids || ids.length === 0) return [];
|
if (!ids || ids.length === 0) return [];
|
||||||
const items = await DriveFiles.findBy({ id: In(ids) });
|
const items = await DriveFiles.findBy({ id: In(ids) });
|
||||||
|
|
|
@ -89,7 +89,7 @@ import * as ep___channels_featured from "./endpoints/channels/featured.js";
|
||||||
import * as ep___channels_follow from "./endpoints/channels/follow.js";
|
import * as ep___channels_follow from "./endpoints/channels/follow.js";
|
||||||
import * as ep___channels_followed from "./endpoints/channels/followed.js";
|
import * as ep___channels_followed from "./endpoints/channels/followed.js";
|
||||||
import * as ep___channels_owned from "./endpoints/channels/owned.js";
|
import * as ep___channels_owned from "./endpoints/channels/owned.js";
|
||||||
import * as ep___channels_search from './endpoints/channels/search.js';
|
import * as ep___channels_search from "./endpoints/channels/search.js";
|
||||||
import * as ep___channels_show from "./endpoints/channels/show.js";
|
import * as ep___channels_show from "./endpoints/channels/show.js";
|
||||||
import * as ep___channels_timeline from "./endpoints/channels/timeline.js";
|
import * as ep___channels_timeline from "./endpoints/channels/timeline.js";
|
||||||
import * as ep___channels_unfollow from "./endpoints/channels/unfollow.js";
|
import * as ep___channels_unfollow from "./endpoints/channels/unfollow.js";
|
||||||
|
@ -439,7 +439,7 @@ const eps = [
|
||||||
["channels/follow", ep___channels_follow],
|
["channels/follow", ep___channels_follow],
|
||||||
["channels/followed", ep___channels_followed],
|
["channels/followed", ep___channels_followed],
|
||||||
["channels/owned", ep___channels_owned],
|
["channels/owned", ep___channels_owned],
|
||||||
['channels/search', ep___channels_search],
|
["channels/search", ep___channels_search],
|
||||||
["channels/show", ep___channels_show],
|
["channels/show", ep___channels_show],
|
||||||
["channels/timeline", ep___channels_timeline],
|
["channels/timeline", ep___channels_timeline],
|
||||||
["channels/unfollow", ep___channels_unfollow],
|
["channels/unfollow", ep___channels_unfollow],
|
||||||
|
|
|
@ -1,38 +1,44 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from "@nestjs/common";
|
||||||
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 { QueryService } from "@/core/QueryService.js";
|
||||||
import type { ChannelsRepository } from '@/models/index.js';
|
import type { ChannelsRepository } from "@/models/index.js";
|
||||||
import { ChannelEntityService } from '@/core/entities/ChannelEntityService.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";
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['channels'],
|
tags: ["channels"],
|
||||||
|
|
||||||
requireCredential: false,
|
requireCredential: false,
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: "array",
|
||||||
optional: false, nullable: false,
|
optional: false,
|
||||||
|
nullable: false,
|
||||||
items: {
|
items: {
|
||||||
type: 'object',
|
type: "object",
|
||||||
optional: false, nullable: false,
|
optional: false,
|
||||||
ref: 'Channel',
|
nullable: false,
|
||||||
|
ref: "Channel",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const paramDef = {
|
export const paramDef = {
|
||||||
type: 'object',
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
query: { type: 'string' },
|
query: { type: "string" },
|
||||||
type: { type: 'string', enum: ['nameAndDescription', 'nameOnly'], default: 'nameAndDescription' },
|
type: {
|
||||||
sinceId: { type: 'string', format: 'misskey:id' },
|
type: "string",
|
||||||
untilId: { type: 'string', format: 'misskey:id' },
|
enum: ["nameAndDescription", "nameOnly"],
|
||||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 5 },
|
default: "nameAndDescription",
|
||||||
|
},
|
||||||
|
sinceId: { type: "string", format: "misskey:id" },
|
||||||
|
untilId: { type: "string", format: "misskey:id" },
|
||||||
|
limit: { type: "integer", minimum: 1, maximum: 100, default: 5 },
|
||||||
},
|
},
|
||||||
required: ['query'],
|
required: ["query"],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
|
@ -46,22 +52,33 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
private queryService: QueryService,
|
private queryService: QueryService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const query = this.queryService.makePaginationQuery(this.channelsRepository.createQueryBuilder('channel'), ps.sinceId, ps.untilId);
|
const query = this.queryService.makePaginationQuery(
|
||||||
|
this.channelsRepository.createQueryBuilder("channel"),
|
||||||
|
ps.sinceId,
|
||||||
|
ps.untilId,
|
||||||
|
);
|
||||||
|
|
||||||
if (ps.type === 'nameAndDescription') {
|
if (ps.type === "nameAndDescription") {
|
||||||
query.andWhere(new Brackets(qb => { qb
|
query.andWhere(
|
||||||
.where('channel.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` })
|
new Brackets((qb) => {
|
||||||
.orWhere('channel.description ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` });
|
qb.where("channel.name ILIKE :q", {
|
||||||
}));
|
q: `%${sqlLikeEscape(ps.query)}%`,
|
||||||
|
}).orWhere("channel.description ILIKE :q", {
|
||||||
|
q: `%${sqlLikeEscape(ps.query)}%`,
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
query.andWhere('channel.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` });
|
query.andWhere("channel.name ILIKE :q", {
|
||||||
|
q: `%${sqlLikeEscape(ps.query)}%`,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const channels = await query
|
const channels = await query.take(ps.limit).getMany();
|
||||||
.take(ps.limit)
|
|
||||||
.getMany();
|
|
||||||
|
|
||||||
return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me)));
|
return await Promise.all(
|
||||||
|
channels.map((x) => this.channelEntityService.pack(x, me)),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -606,8 +606,7 @@ export default async (
|
||||||
});
|
});
|
||||||
|
|
||||||
async function renderNoteOrRenoteActivity(data: Option, note: Note) {
|
async function renderNoteOrRenoteActivity(data: Option, note: Note) {
|
||||||
if (data.localOnly ||
|
if (data.localOnly || note.visibility !== "hidden") return null;
|
||||||
note.visibility !== "hidden") return null;
|
|
||||||
|
|
||||||
const content =
|
const content =
|
||||||
data.renote &&
|
data.renote &&
|
||||||
|
|
|
@ -144,10 +144,7 @@ export default async (
|
||||||
});
|
});
|
||||||
|
|
||||||
//#region deliver
|
//#region deliver
|
||||||
if (
|
if (Users.isLocalUser(user) && !note.localOnly) {
|
||||||
Users.isLocalUser(user) &&
|
|
||||||
!note.localOnly
|
|
||||||
) {
|
|
||||||
const content = renderActivity(await renderLike(record, note));
|
const content = renderActivity(await renderLike(record, note));
|
||||||
const dm = new DeliverManager(user, content);
|
const dm = new DeliverManager(user, content);
|
||||||
if (note.userHost !== null) {
|
if (note.userHost !== null) {
|
||||||
|
|
|
@ -1,31 +1,41 @@
|
||||||
<template>
|
<template>
|
||||||
<MkPagination :pagination="pagination">
|
<MkPagination :pagination="pagination">
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<div class="_fullinfo">
|
<div class="_fullinfo">
|
||||||
<img src="https://xn--931a.moe/assets/info.jpg" class="_ghost"/>
|
<img
|
||||||
<div>{{ i18n.ts.notFound }}</div>
|
src="https://xn--931a.moe/assets/info.jpg"
|
||||||
</div>
|
class="_ghost"
|
||||||
</template>
|
/>
|
||||||
|
<div>{{ i18n.ts.notFound }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #default="{ items }">
|
<template #default="{ items }">
|
||||||
<MkChannelPreview v-for="item in items" :key="item.id" class="_margin" :channel="extractor(item)"/>
|
<MkChannelPreview
|
||||||
</template>
|
v-for="item in items"
|
||||||
</MkPagination>
|
:key="item.id"
|
||||||
|
class="_margin"
|
||||||
|
:channel="extractor(item)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</MkPagination>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import MkChannelPreview from '@/components/MkChannelPreview.vue';
|
import MkChannelPreview from "@/components/MkChannelPreview.vue";
|
||||||
import MkPagination, { Paging } from '@/components/MkPagination.vue';
|
import MkPagination, { Paging } from "@/components/MkPagination.vue";
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from "@/i18n";
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(
|
||||||
pagination: Paging;
|
defineProps<{
|
||||||
noGap?: boolean;
|
pagination: Paging;
|
||||||
extractor?: (item: any) => any;
|
noGap?: boolean;
|
||||||
}>(), {
|
extractor?: (item: any) => any;
|
||||||
extractor: (item) => item,
|
}>(),
|
||||||
});
|
{
|
||||||
|
extractor: (item) => item,
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped></style>
|
||||||
</style>
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ const buttonRef = ref<HTMLElement>();
|
||||||
|
|
||||||
const canRenote = computed(
|
const canRenote = computed(
|
||||||
() =>
|
() =>
|
||||||
["public", "home","hidden"].includes(props.note.visibility) ||
|
["public", "home", "hidden"].includes(props.note.visibility) ||
|
||||||
props.note.userId === $i.id
|
props.note.userId === $i.id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -75,7 +75,10 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
|
||||||
|
|
||||||
let buttonActions = [];
|
let buttonActions = [];
|
||||||
|
|
||||||
if (props.note.visibility === "public" || props.note.visibility === "hidden") {
|
if (
|
||||||
|
props.note.visibility === "public" ||
|
||||||
|
props.note.visibility === "hidden"
|
||||||
|
) {
|
||||||
buttonActions.push({
|
buttonActions.push({
|
||||||
text: i18n.ts.renote,
|
text: i18n.ts.renote,
|
||||||
textStyle: "font-weight: bold",
|
textStyle: "font-weight: bold",
|
||||||
|
@ -102,7 +105,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["public", "home","hidden"].includes(props.note.visibility)) {
|
if (["public", "home", "hidden"].includes(props.note.visibility)) {
|
||||||
buttonActions.push({
|
buttonActions.push({
|
||||||
text: `${i18n.ts.renote} (${i18n.ts._visibility.home})`,
|
text: `${i18n.ts.renote} (${i18n.ts._visibility.home})`,
|
||||||
icon: "ph-house ph-bold ph-lg",
|
icon: "ph-house ph-bold ph-lg",
|
||||||
|
|
|
@ -23,18 +23,44 @@
|
||||||
<swiper-slide>
|
<swiper-slide>
|
||||||
<div class="_content grwlizim search">
|
<div class="_content grwlizim search">
|
||||||
<div class="gaps">
|
<div class="gaps">
|
||||||
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search">
|
<MkInput
|
||||||
<template #prefix><i class="ti ti-search"></i></template>
|
v-model="searchQuery"
|
||||||
|
:large="true"
|
||||||
|
:autofocus="true"
|
||||||
|
type="search"
|
||||||
|
>
|
||||||
|
<template #prefix
|
||||||
|
><i class="ti ti-search"></i
|
||||||
|
></template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
<MkRadios v-model="searchType" @update:model-value="search()">
|
<MkRadios
|
||||||
<option value="nameAndDescription">{{ i18n.ts._channel.nameAndDescription }}</option>
|
v-model="searchType"
|
||||||
<option value="nameOnly">{{ i18n.ts._channel.nameOnly }}</option>
|
@update:model-value="search()"
|
||||||
|
>
|
||||||
|
<option value="nameAndDescription">
|
||||||
|
{{ i18n.ts._channel.nameAndDescription }}
|
||||||
|
</option>
|
||||||
|
<option value="nameOnly">
|
||||||
|
{{ i18n.ts._channel.nameOnly }}
|
||||||
|
</option>
|
||||||
</MkRadios>
|
</MkRadios>
|
||||||
<MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton>
|
<MkButton
|
||||||
|
large
|
||||||
|
primary
|
||||||
|
gradate
|
||||||
|
rounded
|
||||||
|
@click="search"
|
||||||
|
>{{ i18n.ts.search }}</MkButton
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<MkFoldableSection v-if="channelPagination">
|
<MkFoldableSection v-if="channelPagination">
|
||||||
<template #header>{{ i18n.ts.searchResult }}</template>
|
<template #header>{{
|
||||||
<MkChannelList :key="key" :pagination="channelPagination"/>
|
i18n.ts.searchResult
|
||||||
|
}}</template>
|
||||||
|
<MkChannelList
|
||||||
|
:key="key"
|
||||||
|
:pagination="channelPagination"
|
||||||
|
/>
|
||||||
</MkFoldableSection>
|
</MkFoldableSection>
|
||||||
</div>
|
</div>
|
||||||
</swiper-slide>
|
</swiper-slide>
|
||||||
|
@ -96,12 +122,12 @@ import { computed, onMounted, defineComponent, inject, watch } from "vue";
|
||||||
import { Virtual } from "swiper";
|
import { Virtual } from "swiper";
|
||||||
import { Swiper, SwiperSlide } from "swiper/vue";
|
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/MkInput.vue";
|
||||||
import MkRadios from '@/components/MkRadios.vue';
|
import MkRadios from "@/components/MkRadios.vue";
|
||||||
import MkButton from "@/components/MkButton.vue";
|
import MkButton from "@/components/MkButton.vue";
|
||||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
import MkFoldableSection from "@/components/MkFoldableSection.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";
|
||||||
|
@ -120,14 +146,14 @@ const props = defineProps<{
|
||||||
query: string;
|
query: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
}>();
|
}>();
|
||||||
let key = $ref('');
|
let key = $ref("");
|
||||||
let tab = $ref('search');
|
let tab = $ref("search");
|
||||||
let searchQuery = $ref('');
|
let searchQuery = $ref("");
|
||||||
let searchType = $ref('nameAndDescription');
|
let searchType = $ref("nameAndDescription");
|
||||||
let channelPagination = $ref();
|
let channelPagination = $ref();
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
searchQuery = props.query ?? '';
|
searchQuery = props.query ?? "";
|
||||||
searchType = props.type ?? 'nameAndDescription';
|
searchType = props.type ?? "nameAndDescription";
|
||||||
});
|
});
|
||||||
|
|
||||||
const featuredPagination = {
|
const featuredPagination = {
|
||||||
|
@ -146,10 +172,10 @@ const ownedPagination = {
|
||||||
|
|
||||||
async function search() {
|
async function search() {
|
||||||
const query = searchQuery.toString().trim();
|
const query = searchQuery.toString().trim();
|
||||||
if (query == null || query === '') return;
|
if (query == null || query === "") return;
|
||||||
const type = searchType.toString().trim();
|
const type = searchType.toString().trim();
|
||||||
channelPagination = {
|
channelPagination = {
|
||||||
endpoint: 'channels/search',
|
endpoint: "channels/search",
|
||||||
limit: 10,
|
limit: 10,
|
||||||
params: {
|
params: {
|
||||||
query: searchQuery,
|
query: searchQuery,
|
||||||
|
@ -173,9 +199,9 @@ const headerActions = $computed(() => [
|
||||||
|
|
||||||
const headerTabs = $computed(() => [
|
const headerTabs = $computed(() => [
|
||||||
{
|
{
|
||||||
key: 'search',
|
key: "search",
|
||||||
title: i18n.ts.search,
|
title: i18n.ts.search,
|
||||||
icon: 'ti ti-search',
|
icon: "ti ti-search",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "featured",
|
key: "featured",
|
||||||
|
|
Loading…
Reference in a new issue