mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-13 08:57:55 -05:00
Compare commits
2 Commits
fix/slack-
...
fix/slack-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fb6d9d451 | ||
|
|
77241a1220 |
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { ExternalLink, Users } from 'lucide-react'
|
||||
import { Button, Combobox } from '@/components/emcn/components'
|
||||
@@ -29,20 +29,6 @@ import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||
const logger = createLogger('CredentialSelector')
|
||||
const isBillingEnabled = isTruthy(getEnv('NEXT_PUBLIC_BILLING_ENABLED'))
|
||||
|
||||
function useStableCredentialIds(credentials: Array<{ id: string }>) {
|
||||
const knownIdsRef = useRef<Set<string>>(new Set())
|
||||
|
||||
for (const cred of credentials) {
|
||||
knownIdsRef.current.add(cred.id)
|
||||
}
|
||||
|
||||
const isKnownCredentialId = useCallback((id: string): boolean => {
|
||||
return knownIdsRef.current.has(id)
|
||||
}, [])
|
||||
|
||||
return { isKnownCredentialId }
|
||||
}
|
||||
|
||||
interface CredentialSelectorProps {
|
||||
blockId: string
|
||||
subBlock: SubBlockConfig
|
||||
@@ -106,8 +92,6 @@ export function CredentialSelector({
|
||||
refetch: refetchCredentials,
|
||||
} = useOAuthCredentials(effectiveProviderId, Boolean(effectiveProviderId))
|
||||
|
||||
const { isKnownCredentialId } = useStableCredentialIds(credentials)
|
||||
|
||||
const selectedCredential = useMemo(
|
||||
() => credentials.find((cred) => cred.id === selectedId),
|
||||
[credentials, selectedId]
|
||||
@@ -156,8 +140,7 @@ export function CredentialSelector({
|
||||
!selectedCredential &&
|
||||
!hasForeignMeta &&
|
||||
!credentialsLoading &&
|
||||
!foreignMetaLoading &&
|
||||
!isKnownCredentialId(selectedId)
|
||||
!foreignMetaLoading
|
||||
|
||||
useEffect(() => {
|
||||
if (!invalidSelection) return
|
||||
@@ -365,22 +348,10 @@ export function CredentialSelector({
|
||||
return
|
||||
}
|
||||
|
||||
if (isKnownCredentialId(value)) {
|
||||
handleSelect(value)
|
||||
return
|
||||
}
|
||||
|
||||
setIsEditing(true)
|
||||
setInputValue(value)
|
||||
},
|
||||
[
|
||||
credentials,
|
||||
credentialSets,
|
||||
handleAddCredential,
|
||||
handleSelect,
|
||||
handleCredentialSetSelect,
|
||||
isKnownCredentialId,
|
||||
]
|
||||
[credentials, credentialSets, handleAddCredential, handleSelect, handleCredentialSetSelect]
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
@@ -1088,25 +1088,28 @@ export function useCollaborativeWorkflow() {
|
||||
userId: session?.user?.id || 'unknown',
|
||||
})
|
||||
|
||||
const currentValue = subBlockStore.getValue(blockId, subblockId)
|
||||
const valueActuallyChanged = currentValue !== value
|
||||
|
||||
subBlockStore.setValue(blockId, subblockId, value)
|
||||
|
||||
try {
|
||||
const visited = options?._visited || new Set<string>()
|
||||
if (visited.has(subblockId)) return
|
||||
visited.add(subblockId)
|
||||
const blockType = useWorkflowStore.getState().blocks?.[blockId]?.type
|
||||
const blockConfig = blockType ? getBlock(blockType) : null
|
||||
if (blockConfig?.subBlocks && Array.isArray(blockConfig.subBlocks)) {
|
||||
const dependents = blockConfig.subBlocks.filter(
|
||||
(sb: any) => Array.isArray(sb.dependsOn) && sb.dependsOn.includes(subblockId)
|
||||
)
|
||||
for (const dep of dependents) {
|
||||
if (!dep?.id || dep.id === subblockId) continue
|
||||
collaborativeSetSubblockValue(blockId, dep.id, '', { _visited: visited })
|
||||
if (valueActuallyChanged) {
|
||||
try {
|
||||
const visited = options?._visited || new Set<string>()
|
||||
if (visited.has(subblockId)) return
|
||||
visited.add(subblockId)
|
||||
const blockType = useWorkflowStore.getState().blocks?.[blockId]?.type
|
||||
const blockConfig = blockType ? getBlock(blockType) : null
|
||||
if (blockConfig?.subBlocks && Array.isArray(blockConfig.subBlocks)) {
|
||||
const dependents = blockConfig.subBlocks.filter(
|
||||
(sb: any) => Array.isArray(sb.dependsOn) && sb.dependsOn.includes(subblockId)
|
||||
)
|
||||
for (const dep of dependents) {
|
||||
if (!dep?.id || dep.id === subblockId) continue
|
||||
collaborativeSetSubblockValue(blockId, dep.id, '', { _visited: visited })
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Best-effort; do not block on clearing
|
||||
} catch {}
|
||||
}
|
||||
},
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user