init
This commit is contained in:
commit
ec53fcbe95
1905 changed files with 513762 additions and 0 deletions
23
hooks/useMergedClients.ts
Normal file
23
hooks/useMergedClients.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import uniqBy from 'lodash-es/uniqBy.js'
|
||||
import { useMemo } from 'react'
|
||||
import type { MCPServerConnection } from '../services/mcp/types.js'
|
||||
|
||||
export function mergeClients(
|
||||
initialClients: MCPServerConnection[] | undefined,
|
||||
mcpClients: readonly MCPServerConnection[] | undefined,
|
||||
): MCPServerConnection[] {
|
||||
if (initialClients && mcpClients && mcpClients.length > 0) {
|
||||
return uniqBy([...initialClients, ...mcpClients], 'name')
|
||||
}
|
||||
return initialClients || []
|
||||
}
|
||||
|
||||
export function useMergedClients(
|
||||
initialClients: MCPServerConnection[] | undefined,
|
||||
mcpClients: MCPServerConnection[] | undefined,
|
||||
): MCPServerConnection[] {
|
||||
return useMemo(
|
||||
() => mergeClients(initialClients, mcpClients),
|
||||
[initialClients, mcpClients],
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue