Skip to content

Commit

Permalink
enhance: タグ検索においてローカルのみやファイル付きを指定できるように (MisskeyIO#527)
Browse files Browse the repository at this point in the history
cheery-picked from TeamNijimiss/misskey@4fe36c8

Co-authored-by: Nafu Satsuki <satsuki@nafusoft.dev>
  • Loading branch information
u1-liquid and nafu-at authored Mar 16, 2024
1 parent 5c019ee commit c2e1f60
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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');
Expand Down
43 changes: 40 additions & 3 deletions packages/frontend/src/pages/tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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;
}>();
Expand All @@ -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);
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22447,6 +22447,8 @@ export type operations = {
requestBody: {
content: {
'application/json': {
/** @default null */
local?: boolean | null;
/** @default null */
reply?: boolean | null;
/** @default null */
Expand Down

0 comments on commit c2e1f60

Please sign in to comment.