fix: error when fetching info while switching plugins

This commit is contained in:
yessenia
2025-10-11 15:00:35 +08:00
parent ee89e9eb2f
commit 33d7b48e49
3 changed files with 8 additions and 15 deletions

View File

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

View File

@ -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 = {

View File

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