enhance: タグ検索においてローカルのみやファイル付きを指定できるように (MisskeyIO#527)

cheery-picked from TeamNijimiss/misskey@4fe36c8eb9

Co-authored-by: Nafu Satsuki <satsuki@nafusoft.dev>
This commit is contained in:
まっちゃとーにゅ 2024-03-16 17:37:58 +09:00 committed by GitHub
parent 5c019eec04
commit c2e1f60943
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 51 additions and 3 deletions

View File

@ -30,6 +30,7 @@ export const meta = {
export const paramDef = {
type: 'object',
properties: {
local: { type: 'boolean', nullable: true, default: null },
reply: { type: 'boolean', nullable: true, default: null },
renote: { type: 'boolean', nullable: true, default: null },
withFiles: {
@ -105,6 +106,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw e;
}
if (ps.local != null) {
if (ps.local) {
query.andWhere('user.host IS NULL');
} else {
query.andWhere('user.host IS NOT NULL');
}
}
if (ps.reply != null) {
if (ps.reply) {
query.andWhere('note.replyId IS NOT NULL');

View File

@ -5,9 +5,17 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
<MkSpacer :contentMax="800">
<MkNotes ref="notes" class="" :pagination="pagination"/>
<div v-if="tab === 'all'">
<MkNotes class="" :pagination="pagination"/>
</div>
<div v-else-if="tab === 'localOnly'">
<MkNotes class="" :pagination="localOnlyPagination"/>
</div>
<div v-else-if="tab === 'withFiles'">
<MkNotes class="" :pagination="withFilesPagination"/>
</div>
</MkSpacer>
<template v-if="$i" #footer>
<div :class="$style.footer">
@ -29,6 +37,8 @@ import { $i } from '@/account.js';
import { defaultStore } from '@/store.js';
import * as os from '@/os.js';
const tab = ref('all');
const props = defineProps<{
tag: string;
}>();
@ -42,6 +52,24 @@ const pagination = {
};
const notes = ref<InstanceType<typeof MkNotes>>();
const localOnlyPagination = {
endpoint: 'notes/search-by-tag' as const,
limit: 10,
params: computed(() => ({
tag: props.tag,
local: true,
})),
};
const withFilesPagination = {
endpoint: 'notes/search-by-tag' as const,
limit: 10,
params: computed(() => ({
tag: props.tag,
withFiles: true,
})),
};
async function post() {
defaultStore.set('postFormHashtags', props.tag);
defaultStore.set('postFormWithHashtags', true);
@ -53,7 +81,16 @@ async function post() {
const headerActions = computed(() => []);
const headerTabs = computed(() => []);
const headerTabs = computed(() => [{
key: 'all',
title: i18n.ts.all,
}, {
key: 'localOnly',
title: i18n.ts.localOnly,
}, {
key: 'withFiles',
title: i18n.ts.withFiles,
}]);
definePageMetadata(() => ({
title: props.tag,

View File

@ -22447,6 +22447,8 @@ export type operations = {
requestBody: {
content: {
'application/json': {
/** @default null */
local?: boolean | null;
/** @default null */
reply?: boolean | null;
/** @default null */