fix: install button

pull/12560/head
AkaraChen 1 year ago
parent cc0d864599
commit eff6a55960

@ -17,17 +17,19 @@ export const InstallPluginButton = (props: InstallPluginButtonProps) => {
pluginIds: [uniqueIdentifier], pluginIds: [uniqueIdentifier],
enabled: !!uniqueIdentifier, enabled: !!uniqueIdentifier,
}) })
const install = useInstallPackageFromMarketPlace({ const install = useInstallPackageFromMarketPlace()
onSuccess() { const isLoading = manifest.isLoading || install.isPending
manifest.refetch() // await for refetch to get the new installed plugin, when manifest refetch, this component will unmount
onSuccess?.() || install.isSuccess
},
})
const handleInstall: MouseEventHandler = (e) => { const handleInstall: MouseEventHandler = (e) => {
e.stopPropagation() e.stopPropagation()
install.mutate(uniqueIdentifier) install.mutate(uniqueIdentifier, {
onSuccess: async () => {
await manifest.refetch()
onSuccess?.()
},
})
} }
const isLoading = manifest.isLoading || install.isPending
if (!manifest.data) return null if (!manifest.data) return null
if (manifest.data.plugins.some(plugin => plugin.id === uniqueIdentifier)) return null if (manifest.data.plugins.some(plugin => plugin.id === uniqueIdentifier)) return null
return <Button return <Button

Loading…
Cancel
Save