mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 09:58:04 +08:00
fix: error when fetching info while switching plugins
This commit is contained in:
@ -33,13 +33,11 @@ const PluginDetailPanel: FC<Props> = ({
|
|||||||
const { setDetail } = usePluginStore()
|
const { setDetail } = usePluginStore()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (detail) {
|
setDetail(!detail ? undefined : {
|
||||||
setDetail({
|
plugin_id: detail.plugin_id,
|
||||||
plugin_id: detail.plugin_id,
|
provider: `${detail.plugin_id}/${detail.declaration.name}`,
|
||||||
provider: `${detail.plugin_id}/${detail.declaration.name}`,
|
declaration: detail.declaration,
|
||||||
declaration: detail.declaration,
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
}, [detail])
|
}, [detail])
|
||||||
|
|
||||||
if (!detail)
|
if (!detail)
|
||||||
|
|||||||
@ -5,12 +5,12 @@ type SimpleDetail = Pick<PluginDetail, 'plugin_id' | 'declaration'> & { provider
|
|||||||
|
|
||||||
type Shape = {
|
type Shape = {
|
||||||
detail: SimpleDetail | undefined
|
detail: SimpleDetail | undefined
|
||||||
setDetail: (detail: SimpleDetail) => void
|
setDetail: (detail?: SimpleDetail) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const usePluginStore = create<Shape>(set => ({
|
export const usePluginStore = create<Shape>(set => ({
|
||||||
detail: undefined,
|
detail: undefined,
|
||||||
setDetail: (detail: SimpleDetail) => set({ detail }),
|
setDetail: (detail?: SimpleDetail) => set({ detail }),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
type ShapeSubscription = {
|
type ShapeSubscription = {
|
||||||
|
|||||||
@ -84,13 +84,8 @@ export const TriggerEventsList = () => {
|
|||||||
const language = getLanguage(locale)
|
const language = getLanguage(locale)
|
||||||
const detail = usePluginStore(state => state.detail)
|
const detail = usePluginStore(state => state.detail)
|
||||||
const events = detail?.declaration.trigger?.events || []
|
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>(() => {
|
const collection = useMemo<ToolWithProvider | undefined>(() => {
|
||||||
if (!detail || !providerInfo)
|
if (!detail || !providerInfo)
|
||||||
|
|||||||
Reference in New Issue
Block a user