summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2021-02-19 21:40:09 +0900
committersyuilo <syuilotan@yahoo.co.jp>2021-02-19 21:40:09 +0900
commiteefbe097c0e810bbda4108b4235b32bf0456b06f (patch)
tree001c5fc97cbd38caa4c9eaee17c2c043b491a792
parentunisonReload (diff)
downloadsharkey-eefbe097c0e810bbda4108b4235b32bf0456b06f.tar.gz
sharkey-eefbe097c0e810bbda4108b4235b32bf0456b06f.tar.bz2
sharkey-eefbe097c0e810bbda4108b4235b32bf0456b06f.zip
Resolve #7222
-rw-r--r--locales/ja-JP.yml1
-rw-r--r--src/client/pages/search.vue1
-rw-r--r--src/client/ui/chat/index.vue14
-rw-r--r--src/server/api/endpoints/notes/search.ts15
4 files changed, 29 insertions, 2 deletions
diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index 680e70f61e..51a82a32b9 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -704,6 +704,7 @@ editCode: "コードを編集"
apply: "適用"
receiveAnnouncementFromInstance: "インスタンスからのお知らせを受け取る"
emailNotification: "メール通知"
+inChannelSearch: "チャンネル内検索"
_email:
_follow:
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');