mirror of https://github.com/langgenius/dify.git
fix: error when fetching info while switching plugins
This commit is contained in:
parent
ee89e9eb2f
commit
33d7b48e49
|
|
@ -33,13 +33,11 @@ const PluginDetailPanel: FC<Props> = ({
|
|||
const { setDetail } = usePluginStore()
|
||||
|
||||
useEffect(() => {
|
||||
if (detail) {
|
||||
setDetail({
|
||||
plugin_id: detail.plugin_id,
|
||||
provider: `${detail.plugin_id}/${detail.declaration.name}`,
|
||||
declaration: detail.declaration,
|
||||
})
|
||||
}
|
||||
setDetail(!detail ? undefined : {
|
||||
plugin_id: detail.plugin_id,
|
||||
provider: `${detail.plugin_id}/${detail.declaration.name}`,
|
||||
declaration: detail.declaration,
|
||||
})
|
||||
}, [detail])
|
||||
|
||||
if (!detail)
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ type SimpleDetail = Pick<PluginDetail, 'plugin_id' | 'declaration'> & { provider
|
|||
|
||||
type Shape = {
|
||||
detail: SimpleDetail | undefined
|
||||
setDetail: (detail: SimpleDetail) => void
|
||||
setDetail: (detail?: SimpleDetail) => void
|
||||
}
|
||||
|
||||
export const usePluginStore = create<Shape>(set => ({
|
||||
detail: undefined,
|
||||
setDetail: (detail: SimpleDetail) => set({ detail }),
|
||||
setDetail: (detail?: SimpleDetail) => set({ detail }),
|
||||
}))
|
||||
|
||||
type ShapeSubscription = {
|
||||
|
|
|
|||
|
|
@ -84,13 +84,8 @@ export const TriggerEventsList = () => {
|
|||
const language = getLanguage(locale)
|
||||
const detail = usePluginStore(state => state.detail)
|
||||
const events = detail?.declaration.trigger?.events || []
|
||||
const providerKey = useMemo(() => {
|
||||
if (!detail?.plugin_id || !detail?.declaration?.name)
|
||||
return ''
|
||||
return `${detail.plugin_id}/${detail.declaration.name}`
|
||||
}, [detail?.plugin_id, detail?.declaration?.name])
|
||||
|
||||
const { data: providerInfo } = useTriggerProviderInfo(providerKey, !!providerKey)
|
||||
const { data: providerInfo } = useTriggerProviderInfo(detail?.provider || '')
|
||||
|
||||
const collection = useMemo<ToolWithProvider | undefined>(() => {
|
||||
if (!detail || !providerInfo)
|
||||
|
|
|
|||
Loading…
Reference in New Issue