feat: hotfix for mentions

This commit is contained in:
Nevo David 2025-08-03 12:32:41 +07:00
parent a4c80c73a6
commit 142239403c
3 changed files with 20 additions and 17 deletions

View File

@ -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')

View File

@ -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',

View File

@ -91,7 +91,7 @@ const MentionList: FC = (props: any) => {
props.items.length === 0 ? (
<div className="p-2 text-gray-500 text-center">No results found</div>
) : (
props.items.map((item: any, index: any) => (
props?.items?.map((item: any, index: any) => (
<button
className={`flex gap-[10px] w-full p-2 text-left rounded hover:bg-gray-100 ${
index === selectedIndex ? 'bg-blue-100' : ''