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

View File

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

View File

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