Skip to content

Commit

Permalink
[CP-3128] Cancel action handling for closing terminal information has…
Browse files Browse the repository at this point in the history
… been implemented
  • Loading branch information
dkarski committed Oct 10, 2024
1 parent 5abb8bc commit 3c15214
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ import { createAsyncThunk } from "@reduxjs/toolkit"
import { ActionName } from "generic-view/store"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import { selectFlashingAbortController } from "../selectors/select-flashing-abort-controller"
import { setFlashingProcessState } from "./set-flashing-process-state/set-flashing-process-state.action"
import { FlashingProcessState } from "../constants"

export const abortMscFlashing = createAsyncThunk<
void,
undefined,
{ reason?: Extract<FlashingProcessState, "canceled" | "failed"> } | undefined,
{ state: ReduxRootState }
>(ActionName.MscFlashingAbort, async (_, { getState }) => {
const abortController = selectFlashingAbortController(getState())
>(
ActionName.MscFlashingAbort,
async ({ reason } = {}, { dispatch, getState }) => {
const abortController = selectFlashingAbortController(getState())

abortController?.abort?.()
abortController?.abort?.()

return
})
if (reason) {
dispatch(setFlashingProcessState(reason))
}

return
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export enum FlashingProcessState {
TerminalOpened = "terminal-opened",
Restarting = "restarting-device",
Completed = "completed",
Canceled = "canceled",
Failed = "failed",
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,9 @@ const startFlashingProcess = async (
await deviceFlash.waitForFlashCompletion({ signal: abortController.signal })

dispatch(setFlashingProcessState(FlashingProcessState.Restarting))
// TODO: for mac - to check
// dispatch(setFlashingProcessState(FlashingProcessState.Completed))
await removeDownloadedMscFiles()

// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
throw new Error(`Flash process failed with error: ${error}`)
await removeDownloadedMscFiles()
} catch (error) {
throw new Error(`Flash process failed with error: ${JSON.stringify(error)}`)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const MacTerminalInfoModal: FunctionComponent<
closeable={true}
closeButton={false}
closeModal={onClose}
onClose={onClose}
>
<ModalContent>
<RoundIconWrapper>
Expand Down
4 changes: 2 additions & 2 deletions libs/msc-flash/msc-flash-harmony/src/lib/ui/recovery-mode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { FlashingProcessState } from "../constants"
import theme from "Core/core/styles/theming/theme"
import { RestartingDeviceModal } from "./restarting-device-modal/restarting-device-modal.component"
import { ErrorHandlingModal } from "./error-handling-modal/error-handling-modal.component"
import { setFlashingProcessState } from "../actions"
import { abortMscFlashing, setFlashingProcessState } from "../actions"
import { MacTerminalInfoModal } from "./mac-terminal-info-modal/mac-terminal-info-modal.component"

const messages = defineMessages({
Expand Down Expand Up @@ -145,7 +145,7 @@ const RecoveryModeUI: FunctionComponent = () => {
}

const macTerminalInfoCloseHandler = (): void => {
dispatch(setFlashingProcessState(FlashingProcessState.Completed))
dispatch(abortMscFlashing({ reason: FlashingProcessState.Canceled }))
}

return (
Expand Down

0 comments on commit 3c15214

Please sign in to comment.