From 142239403c54aa1fb80965bcf349ae37a41334e8 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Sun, 3 Aug 2025 12:32:41 +0700 Subject: [PATCH] feat: hotfix for mentions --- .../src/api/routes/integrations.controller.ts | 32 +++++++++++-------- .../src/components/new-launch/editor.tsx | 3 -- .../new-launch/mention.component.tsx | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/apps/backend/src/api/routes/integrations.controller.ts b/apps/backend/src/api/routes/integrations.controller.ts index da43888a..1f90e65f 100644 --- a/apps/backend/src/api/routes/integrations.controller.ts +++ b/apps/backend/src/api/routes/integrations.controller.ts @@ -261,24 +261,30 @@ export class IntegrationsController { throw new Error('Invalid integration'); } + let newList: any[] | {none: true} = []; + try { + newList = await this.functionIntegration(org, body); + } catch (err) {} + + if (!Array.isArray(newList) && newList?.none) { + return newList; + } + const list = await this._integrationService.getMentions( getIntegration.providerIdentifier, body?.data?.query ); - let newList = []; - try { - newList = await this.functionIntegration(org, body); - } catch (err) {} - - if (newList.length) { + if (Array.isArray(newList) && newList.length) { await this._integrationService.insertMentions( getIntegration.providerIdentifier, - newList.map((p: any) => ({ - name: p.label || '', - username: p.id || '', - image: p.image || '', - })).filter((f: any) => f.name) + newList + .map((p: any) => ({ + name: p.label || '', + username: p.id || '', + image: p.image || '', + })) + .filter((f: any) => f.name) ); } @@ -289,10 +295,10 @@ export class IntegrationsController { image: p.image, label: p.name, })), - ...newList, + ...newList as any[], ], (p) => p.id - ).filter(f => f.label && f.image && f.id); + ).filter((f) => f.label && f.image && f.id); } @Post('/function') diff --git a/apps/frontend/src/components/new-launch/editor.tsx b/apps/frontend/src/components/new-launch/editor.tsx index 333cb308..5105ac7d 100644 --- a/apps/frontend/src/components/new-launch/editor.tsx +++ b/apps/frontend/src/components/new-launch/editor.tsx @@ -52,10 +52,7 @@ import Heading from '@tiptap/extension-heading'; import { HeadingComponent } from '@gitroom/frontend/components/new-launch/heading.component'; import Mention from '@tiptap/extension-mention'; import { suggestion } from '@gitroom/frontend/components/new-launch/mention.component'; -import { useCustomProviderFunction } from '@gitroom/frontend/components/launches/helpers/use.custom.provider.function'; -import { useIntegration } from '@gitroom/frontend/components/launches/helpers/use.integration'; import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; -import { useDebouncedCallback } from 'use-debounce'; const InterceptBoldShortcut = Extension.create({ name: 'preventBoldWithUnderline', diff --git a/apps/frontend/src/components/new-launch/mention.component.tsx b/apps/frontend/src/components/new-launch/mention.component.tsx index 8de4fb55..3f93caeb 100644 --- a/apps/frontend/src/components/new-launch/mention.component.tsx +++ b/apps/frontend/src/components/new-launch/mention.component.tsx @@ -91,7 +91,7 @@ const MentionList: FC = (props: any) => { props.items.length === 0 ? (
No results found
) : ( - props.items.map((item: any, index: any) => ( + props?.items?.map((item: any, index: any) => (