From 1c35cbf390bac05fcac487acf34f46972ec05cff Mon Sep 17 00:00:00 2001 From: Romaric Mourgues Date: Sun, 3 Jul 2022 15:15:00 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Make=20search=20popup=20re?= =?UTF-8?q?cent=20faster=20to=20display=20(#2384)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix it * Adjust query --- twake/backend/node/src/services/user/services/users/service.ts | 3 ++- .../src/app/features/search/hooks/use-search-channels.ts | 2 +- .../app/features/search/hooks/use-search-files-or-medias.ts | 2 +- .../src/app/features/search/hooks/use-search-messages.ts | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/twake/backend/node/src/services/user/services/users/service.ts b/twake/backend/node/src/services/user/services/users/service.ts index d40d7d9bba..cd43e3d0a5 100644 --- a/twake/backend/node/src/services/user/services/users/service.ts +++ b/twake/backend/node/src/services/user/services/users/service.ts @@ -28,7 +28,7 @@ import PasswordEncoder from "../../../../utils/password-encoder"; import assert from "assert"; import { localEventBus } from "../../../../core/platform/framework/pubsub"; import { ResourceEventsPayload } from "../../../../utils/types"; -import { isNumber } from "lodash"; +import { isNumber, isString } from "lodash"; import { RealtimeSaved } from "../../../../core/platform/framework"; import { getUserRoom } from "../../realtime"; import NodeCache from "node-cache"; @@ -236,6 +236,7 @@ export class UserServiceImpl implements UsersService { } async getCached(pk: UserPrimaryKey): Promise { + if (!(pk.id && isString(pk.id))) return null; if (this.cache.has(pk.id)) return this.cache.get(pk.id); const entity = await this.get(pk); this.cache.set(pk.id, entity); diff --git a/twake/frontend/src/app/features/search/hooks/use-search-channels.ts b/twake/frontend/src/app/features/search/hooks/use-search-channels.ts index 1d420cea3a..ad10084115 100644 --- a/twake/frontend/src/app/features/search/hooks/use-search-channels.ts +++ b/twake/frontend/src/app/features/search/hooks/use-search-channels.ts @@ -51,7 +51,7 @@ export const useSearchChannels = () => { const [searched, setSearched] = useRecoilState(SearchChannelsResultsState(companyId)); const [recent, setRecent] = useRecoilState(RecentChannelsState(companyId)); - const opt = { limit: 100, company_id: companyId }; + const opt = { limit: 25, company_id: companyId }; const refresh = async () => { setLoading(true); diff --git a/twake/frontend/src/app/features/search/hooks/use-search-files-or-medias.ts b/twake/frontend/src/app/features/search/hooks/use-search-files-or-medias.ts index 03f2524f91..45b20976d4 100644 --- a/twake/frontend/src/app/features/search/hooks/use-search-files-or-medias.ts +++ b/twake/frontend/src/app/features/search/hooks/use-search-files-or-medias.ts @@ -40,7 +40,7 @@ export const useSearchMessagesFilesOrMedias = (mode: 'files' | 'medias') => { const opt = _.omitBy( { - limit: 100, + limit: 25, is_file: mode === 'files' || undefined, is_media: mode === 'medias' || undefined, workspace_id: searchInput.workspaceId, diff --git a/twake/frontend/src/app/features/search/hooks/use-search-messages.ts b/twake/frontend/src/app/features/search/hooks/use-search-messages.ts index 301a49c892..e17922b6f6 100644 --- a/twake/frontend/src/app/features/search/hooks/use-search-messages.ts +++ b/twake/frontend/src/app/features/search/hooks/use-search-messages.ts @@ -25,7 +25,7 @@ export const useSearchMessages = () => { const opt = _.omitBy( { - limit: 100, + limit: 50, company_id: companyId, workspace_id: searchInput.workspaceId, channel_id: searchInput.channelId,