-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CP-3170] Minor refactor of device-flash (#2128)
- Loading branch information
Showing
17 changed files
with
97 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
libs/core/core/hooks/use-abort-flashing-on-device-detached.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright (c) Mudita sp. z o.o. All rights reserved. | ||
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md | ||
*/ | ||
|
||
import { useCallback, useEffect } from "react" | ||
import { useDispatch, useSelector } from "react-redux" | ||
import { answerMain, useDebouncedEventsHandler } from "shared/utils" | ||
import { | ||
DeviceBaseProperties, | ||
DeviceProtocolMainEvent, | ||
DeviceType, | ||
} from "device-protocol/models" | ||
import { | ||
abortMscFlashing, | ||
FlashingProcessState, | ||
selectIsFlashingInActivePhases, | ||
} from "msc-flash-harmony" | ||
import { Dispatch } from "Core/__deprecated__/renderer/store" | ||
|
||
export const useMscDeviceDetachedEffect = () => { | ||
const handleDevicesDetached = useHandleDevicesDetached() | ||
|
||
const batchDeviceDetachedEvents = | ||
useDebouncedEventsHandler<DeviceBaseProperties>(handleDevicesDetached) | ||
|
||
useEffect(() => { | ||
return answerMain( | ||
DeviceProtocolMainEvent.DeviceDetached, | ||
batchDeviceDetachedEvents | ||
) | ||
}, [batchDeviceDetachedEvents]) | ||
} | ||
|
||
const useHandleDevicesDetached = () => { | ||
const dispatch = useDispatch<Dispatch>() | ||
const flashingInActivePhases = useSelector(selectIsFlashingInActivePhases) | ||
return useCallback( | ||
(deviceDetachedEvents: DeviceBaseProperties[]) => { | ||
const mscEvents = deviceDetachedEvents.filter( | ||
({ deviceType }) => deviceType === DeviceType.MuditaHarmonyMsc | ||
) | ||
|
||
if (mscEvents.length === 0) { | ||
return | ||
} | ||
|
||
const reason = flashingInActivePhases | ||
? FlashingProcessState.Failed | ||
: undefined | ||
dispatch(abortMscFlashing({ reason })) | ||
}, | ||
[dispatch, flashingInActivePhases] | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
88 changes: 0 additions & 88 deletions
88
libs/msc-flash/msc-flash-harmony/src/lib/services/device-flash/linux-device-flash.service.ts
This file was deleted.
Oops, something went wrong.
79 changes: 0 additions & 79 deletions
79
.../msc-flash/msc-flash-harmony/src/lib/services/device-flash/linux-partition-parser.test.ts
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
libs/msc-flash/msc-flash-harmony/src/lib/services/device-flash/linux-partition-parser.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.