From 10f466c895027e6226c17b39fcb28cdf78e2af4d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 2 Dec 2018 06:44:18 +0900 Subject: [PATCH] Improve performance --- .../app/common/views/components/autocomplete.vue | 3 ++- src/client/app/common/views/components/messaging.vue | 3 ++- src/server/api/endpoints/users/search.ts | 11 +++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/client/app/common/views/components/autocomplete.vue b/src/client/app/common/views/components/autocomplete.vue index f1f85ba40..d61c598ec 100644 --- a/src/client/app/common/views/components/autocomplete.vue +++ b/src/client/app/common/views/components/autocomplete.vue @@ -187,7 +187,8 @@ export default Vue.extend({ } else { this.$root.api('users/search', { query: this.q, - limit: 10 + limit: 10, + detail: false }).then(users => { this.users = users; this.fetching = false; diff --git a/src/client/app/common/views/components/messaging.vue b/src/client/app/common/views/components/messaging.vue index 1b22571cd..7016695e2 100644 --- a/src/client/app/common/views/components/messaging.vue +++ b/src/client/app/common/views/components/messaging.vue @@ -116,7 +116,8 @@ export default Vue.extend({ this.$root.api('users/search', { query: this.q, localOnly: true, - limit: 10 + limit: 10, + detail: false }).then(users => { this.result = users.filter(user => user.id != this.$store.state.i.id); }); diff --git a/src/server/api/endpoints/users/search.ts b/src/server/api/endpoints/users/search.ts index 85138fa6e..f7f179496 100644 --- a/src/server/api/endpoints/users/search.ts +++ b/src/server/api/endpoints/users/search.ts @@ -41,6 +41,14 @@ export const meta = { 'ja-JP': 'ローカルユーザーのみ検索対象にするか否か' } }, + + detail: { + validator: $.bool.optional, + default: true, + desc: { + 'ja-JP': '詳細なユーザー情報を含めるか否か' + } + }, }, }; @@ -72,6 +80,5 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { } } - // Serialize - res(await Promise.all(users.map(user => pack(user, me, { detail: true })))); + res(await Promise.all(users.map(user => pack(user, me, { detail: ps.detail })))); }));