diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/pages/search.vue | 1 | ||||
| -rw-r--r-- | src/client/ui/chat/index.vue | 14 | ||||
| -rw-r--r-- | src/server/api/endpoints/notes/search.ts | 15 |
3 files changed, 28 insertions, 2 deletions
diff --git a/src/client/pages/search.vue b/src/client/pages/search.vue index ed92243cd2..5e79531b20 100644 --- a/src/client/pages/search.vue +++ b/src/client/pages/search.vue @@ -28,6 +28,7 @@ export default defineComponent({ limit: 10, params: () => ({ query: this.$route.query.q, + channelId: this.$route.query.channel, }) }, }; diff --git a/src/client/ui/chat/index.vue b/src/client/ui/chat/index.vue index 79c0d53074..44f47447a7 100644 --- a/src/client/ui/chat/index.vue +++ b/src/client/ui/chat/index.vue @@ -99,7 +99,10 @@ <div class="right"> <div class="instance">{{ instanceName }}</div> <XHeaderClock class="clock"/> - <button class="_button button search" @click="search" v-tooltip="$ts.search"> + <button class="_button button search" v-if="tl.startsWith('channel:') && currentChannel" @click="inChannelSearch" v-tooltip="$ts.inChannelSearch"> + <Fa :icon="faSearch"/> + </button> + <button class="_button button search" v-else @click="search" v-tooltip="$ts.search"> <Fa :icon="faSearch"/> </button> <button class="_button button follow" v-if="tl.startsWith('channel:') && currentChannel" :class="{ followed: currentChannel.isFollowing }" @click="toggleChannelFollow" v-tooltip="currentChannel.isFollowing ? $ts.unfollow : $ts.follow"> @@ -249,6 +252,15 @@ export default defineComponent({ search(); }, + async inChannelSearch() { + const { canceled, result: query } = await os.dialog({ + title: this.$ts.inChannelSearch, + input: true + }); + if (canceled || query == null || query === '') return; + router.push(`/search?q=${encodeURIComponent(query)}&channel=${this.currentChannel.id}`); + }, + top() { window.scroll({ top: 0, behavior: 'smooth' }); }, diff --git a/src/server/api/endpoints/notes/search.ts b/src/server/api/endpoints/notes/search.ts index 2c75d2a55a..1aca056299 100644 --- a/src/server/api/endpoints/notes/search.ts +++ b/src/server/api/endpoints/notes/search.ts @@ -46,6 +46,11 @@ export const meta = { validator: $.optional.nullable.type(ID), default: null }, + + channelId: { + validator: $.optional.nullable.type(ID), + default: null + }, }, res: { @@ -64,7 +69,15 @@ export const meta = { export default define(meta, async (ps, me) => { if (es == null) { - const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId) + const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId); + + if (ps.userId) { + query.andWhere('note.userId = :userId', { userId: ps.userId }); + } else if (ps.channelId) { + query.andWhere('note.channelId = :channelId', { channelId: ps.channelId }); + } + + query .andWhere('note.text ILIKE :q', { q: `%${ps.query}%` }) .leftJoinAndSelect('note.user', 'user'); |