Skip to content

Commit

Permalink
fix: enable when works are finished
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Sep 23, 2022
1 parent c46e9be commit 0d3c6c7
Showing 1 changed file with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ const GameChallengeEdit: FC = () => {
})
.catch(showErrorNotification)
.finally(() => {
setDisabled(false)
if (!noFeedback) {
setDisabled(false)
}
})
}
}
Expand Down Expand Up @@ -136,33 +138,36 @@ const GameChallengeEdit: FC = () => {
})
}

const onDestroyTestContainer = () => {
api.edit
.editDestroyTestContainer(numId, numCId)
.then(() => {
showNotification({
color: 'teal',
message: '实例已销毁',
icon: <Icon path={mdiCheck} size={1} />,
disallowClose: true,
})
if (challenge) mutate({ ...challenge, testContainer: undefined })
})
.catch(showErrorNotification)
.finally(() => {
setDisabled(false)
})
}

const onToggleTestContainer = () => {
if (!challenge) return

setDisabled(true)
if (!challenge?.testContainer) {
onUpdate({
onUpdate(
{
...challengeInfo,
tag: tag as ChallengeTag,
minScoreRate: minRate / 100,
}, true)?.then(onCreateTestContainer)
} else {
api.edit
.editDestroyTestContainer(numId, numCId)
.then(() => {
showNotification({
color: 'teal',
message: '实例已销毁',
icon: <Icon path={mdiCheck} size={1} />,
disallowClose: true,
})
mutate({ ...challenge, testContainer: undefined })
})
.catch(showErrorNotification)
.finally(() => {
setDisabled(false)
})
}
},
true
)?.then(challenge?.testContainer ? onDestroyTestContainer : onCreateTestContainer)
}

return (
Expand Down

0 comments on commit 0d3c6c7

Please sign in to comment.