diff --git a/lib/gui/app/app.ts b/lib/gui/app/app.ts index f177a9e9..aa473d95 100644 --- a/lib/gui/app/app.ts +++ b/lib/gui/app/app.ts @@ -23,17 +23,13 @@ import * as ReactDOM from 'react-dom'; import { v4 as uuidV4 } from 'uuid'; import * as packageJSON from '../../../package.json'; -import { - DrivelistDrive, - isDriveValid, - isSourceDrive, -} from '../../shared/drive-constraints'; +import { DrivelistDrive, isSourceDrive } from '../../shared/drive-constraints'; import * as EXIT_CODES from '../../shared/exit-codes'; import * as messages from '../../shared/messages'; import * as availableDrives from './models/available-drives'; import * as flashState from './models/flash-state'; import { init as ledsInit } from './models/leds'; -import { deselectImage, getImage, selectDrive } from './models/selection-state'; +import { deselectImage, getImage } from './models/selection-state'; import * as settings from './models/settings'; import { Actions, observe, store } from './models/store'; import * as analytics from './modules/analytics'; @@ -251,14 +247,6 @@ async function addDrive(drive: Drive) { const drives = getDrives(); drives[preparedDrive.device] = preparedDrive; setDrives(drives); - if ( - (await settings.get('autoSelectAllDrives')) && - drive instanceof sdk.sourceDestination.BlockDevice && - // @ts-ignore BlockDevice.drive is private - isDriveValid(drive.drive, getImage()) - ) { - selectDrive(drive.device); - } } function removeDrive(drive: Drive) { diff --git a/lib/gui/app/components/target-selector/target-selector.tsx b/lib/gui/app/components/target-selector/target-selector.tsx index 2ec79ddd..b3b5d55e 100644 --- a/lib/gui/app/components/target-selector/target-selector.tsx +++ b/lib/gui/app/components/target-selector/target-selector.tsx @@ -29,7 +29,6 @@ import { deselectDrive, selectDrive, } from '../../models/selection-state'; -import * as settings from '../../models/settings'; import { observe } from '../../models/store'; import * as analytics from '../../modules/analytics'; import { TargetSelectorButton } from './target-selector-button'; @@ -45,12 +44,7 @@ export const getDriveListLabel = () => { .join('\n'); }; -const shouldShowDrivesButton = () => { - return !settings.getSync('disableExplicitDriveSelection'); -}; - const getDriveSelectionStateSlice = () => ({ - showDrivesButton: shouldShowDrivesButton(), driveListLabel: getDriveListLabel(), targets: getSelectedDrives(), image: getImage(), @@ -114,10 +108,9 @@ export const TargetSelector = ({ flashing, }: TargetSelectorProps) => { // TODO: inject these from redux-connector - const [ - { showDrivesButton, driveListLabel, targets }, - setStateSlice, - ] = React.useState(getDriveSelectionStateSlice()); + const [{ driveListLabel, targets }, setStateSlice] = React.useState( + getDriveSelectionStateSlice(), + ); const [showTargetSelectorModal, setShowTargetSelectorModal] = React.useState( false, ); @@ -141,7 +134,7 @@ export const TargetSelector = ({ { setShowTargetSelectorModal(true); diff --git a/lib/gui/app/models/store.ts b/lib/gui/app/models/store.ts index f167dfa9..bfcf05ba 100644 --- a/lib/gui/app/models/store.ts +++ b/lib/gui/app/models/store.ts @@ -175,7 +175,7 @@ function storeReducer( ); const shouldAutoselectAll = Boolean( - settings.getSync('disableExplicitDriveSelection'), + settings.getSync('autoSelectAllDrives'), ); const AUTOSELECT_DRIVE_COUNT = 1; const nonStaleSelectedDevices = nonStaleNewState @@ -197,18 +197,12 @@ function storeReducer( drives, (accState, drive) => { if ( - _.every([ - constraints.isDriveValid(drive, image), - constraints.isDriveSizeRecommended(drive, image), - - // We don't want to auto-select large drives - !constraints.isDriveSizeLarge(drive), - - // We don't want to auto-select system drives, - // even when "unsafe mode" is enabled - !constraints.isSystemDrive(drive), - ]) || - (shouldAutoselectAll && constraints.isDriveValid(drive, image)) + constraints.isDriveValid(drive, image) && + constraints.isDriveSizeRecommended(drive, image) && + // We don't want to auto-select large drives execpt is autoSelectAllDrives is true + (!constraints.isDriveSizeLarge(drive) || shouldAutoselectAll) && + // We don't want to auto-select system drives + !constraints.isSystemDrive(drive) ) { // Auto-select this drive return storeReducer(accState, {