Skip to content

Commit

Permalink
fix(app): fix manual file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Dec 12, 2024
1 parent 09febe7 commit 1434e0b
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ExternalLink } from '/app/atoms/Link/ExternalLink'
import { TertiaryButton } from '/app/atoms/buttons'
import { getRobotUpdateDisplayInfo } from '/app/redux/robot-update'
import { useDispatchStartRobotUpdate } from '/app/redux/robot-update/hooks'
import { remote } from '/app/redux/shell/remote'

import type { ChangeEventHandler, MouseEventHandler } from 'react'
import type { State } from '/app/redux/types'
Expand Down Expand Up @@ -55,14 +56,19 @@ export function UpdateRobotSoftware({

const handleChange: ChangeEventHandler<HTMLInputElement> = event => {
const { files } = event.target
if (files?.length === 1 && !updateDisabled) {
dispatchStartRobotUpdate(robotName, files[0].path)
onUpdateStart()
}
// this is to reset the state of the file picker so users can reselect the same
// system image if the upload fails
if (inputRef.current?.value != null) {
inputRef.current.value = ''

if (files != null) {
void remote.getFilePathFrom(files[0]).then(filePath => {
if (files?.length === 1 && !updateDisabled) {
dispatchStartRobotUpdate(robotName, filePath)
onUpdateStart()
}
// this is to reset the state of the file picker so users can reselect the same
// system image if the upload fails
if (inputRef.current?.value != null) {
inputRef.current.value = ''
}
})
}
}

Expand Down

0 comments on commit 1434e0b

Please sign in to comment.