Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): fix manual file upload #17098

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading