fix: other install error

pull/12372/head
Joel 1 year ago
parent 84cad5969e
commit b78ab0bd69

@ -2,7 +2,7 @@
import React from 'react' import React from 'react'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import type { PluginDeclaration, PluginType, UpdateFromGitHubPayload } from '../../../types' import { type PluginDeclaration, type PluginType, TaskStatus, type UpdateFromGitHubPayload } from '../../../types'
import Card from '../../../card' import Card from '../../../card'
import Badge, { BadgeState } from '@/app/components/base/badge/index' import Badge, { BadgeState } from '@/app/components/base/badge/index'
import { pluginManifestToCardPluginProps } from '../../utils' import { pluginManifestToCardPluginProps } from '../../utils'
@ -53,8 +53,9 @@ const Loaded: React.FC<LoadedProps> = ({
try { try {
const { owner, repo } = parseGitHubUrl(repoUrl) const { owner, repo } = parseGitHubUrl(repoUrl)
let taskId
if (updatePayload) { if (updatePayload) {
const { all_installed: isInstalled, task_id: taskId } = await updateFromGitHub( const { all_installed: isInstalled, task_id } = await updateFromGitHub(
`${owner}/${repo}`, `${owner}/${repo}`,
selectedVersion, selectedVersion,
selectedPackage, selectedPackage,
@ -62,40 +63,42 @@ const Loaded: React.FC<LoadedProps> = ({
uniqueIdentifier, uniqueIdentifier,
) )
taskId = task_id
if (isInstalled) { if (isInstalled) {
onInstalled() onInstalled()
return return
} }
handleRefetch() handleRefetch()
await check({
taskId,
pluginUniqueIdentifier: uniqueIdentifier,
})
onInstalled()
} }
else { else {
const { all_installed: isInstalled, task_id: taskId } = await installPackageFromGitHub({ const { all_installed: isInstalled, task_id } = await installPackageFromGitHub({
repoUrl: `${owner}/${repo}`, repoUrl: `${owner}/${repo}`,
selectedVersion, selectedVersion,
selectedPackage, selectedPackage,
uniqueIdentifier, uniqueIdentifier,
}) })
taskId = task_id
if (isInstalled) { if (isInstalled) {
onInstalled() onInstalled()
return return
} }
handleRefetch() handleRefetch()
await check({ }
taskId,
pluginUniqueIdentifier: uniqueIdentifier,
})
onInstalled() const { status, error } = await check({
taskId,
pluginUniqueIdentifier: uniqueIdentifier,
})
if (status === TaskStatus.failed) {
onFailed(error)
return
} }
onInstalled()
} }
catch (e) { catch (e) {
if (typeof e === 'string') { if (typeof e === 'string') {

@ -2,7 +2,7 @@
import type { FC } from 'react' import type { FC } from 'react'
import React, { useEffect } from 'react' import React, { useEffect } from 'react'
// import { RiInformation2Line } from '@remixicon/react' // import { RiInformation2Line } from '@remixicon/react'
import type { Plugin, PluginManifestInMarket } from '../../../types' import { type Plugin, type PluginManifestInMarket, TaskStatus } from '../../../types'
import Card from '../../../card' import Card from '../../../card'
import { pluginManifestInMarketToPluginProps } from '../../utils' import { pluginManifestInMarketToPluginProps } from '../../utils'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
@ -93,10 +93,14 @@ const Installed: FC<Props> = ({
onInstalled() onInstalled()
return return
} }
await check({ const { status, error } = await check({
taskId, taskId,
pluginUniqueIdentifier: uniqueIdentifier, pluginUniqueIdentifier: uniqueIdentifier,
}) })
if (status === TaskStatus.failed) {
onFailed(error)
return
}
onInstalled() onInstalled()
} }
catch (e) { catch (e) {

@ -7,12 +7,13 @@ import Card from '@/app/components/plugins/card'
import Modal from '@/app/components/base/modal' import Modal from '@/app/components/base/modal'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import Badge, { BadgeState } from '@/app/components/base/badge/index' import Badge, { BadgeState } from '@/app/components/base/badge/index'
import type { UpdateFromMarketPlacePayload } from '../types' import { TaskStatus, type UpdateFromMarketPlacePayload } from '../types'
import { pluginManifestToCardPluginProps } from '@/app/components/plugins/install-plugin/utils' import { pluginManifestToCardPluginProps } from '@/app/components/plugins/install-plugin/utils'
import useGetIcon from '../install-plugin/base/use-get-icon' import useGetIcon from '../install-plugin/base/use-get-icon'
import { updateFromMarketPlace } from '@/service/plugins' import { updateFromMarketPlace } from '@/service/plugins'
import checkTaskStatus from '@/app/components/plugins/install-plugin/base/check-task-status' import checkTaskStatus from '@/app/components/plugins/install-plugin/base/check-task-status'
import { usePluginTaskList } from '@/service/use-plugins' import { usePluginTaskList } from '@/service/use-plugins'
import Toast from '../../base/toast'
const i18nPrefix = 'plugin.upgrade' const i18nPrefix = 'plugin.upgrade'
@ -83,10 +84,14 @@ const UpdatePluginModal: FC<Props> = ({
return return
} }
handleRefetch() handleRefetch()
await check({ const { status, error } = await check({
taskId, taskId,
pluginUniqueIdentifier: targetPackageInfo.id, pluginUniqueIdentifier: targetPackageInfo.id,
}) })
if (status === TaskStatus.failed) {
Toast.notify({ type: 'error', message: error! })
return
}
onSave() onSave()
} }
// eslint-disable-next-line unused-imports/no-unused-vars // eslint-disable-next-line unused-imports/no-unused-vars

Loading…
Cancel
Save