autoSelectAllDrives setting

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2020-07-01 18:58:54 +02:00
parent 9bde38df5a
commit 5c5273bd6c

View File

@ -23,13 +23,13 @@ import * as ReactDOM from 'react-dom';
import { v4 as uuidV4 } from 'uuid'; import { v4 as uuidV4 } from 'uuid';
import * as packageJSON from '../../../package.json'; import * as packageJSON from '../../../package.json';
import { isSourceDrive } from '../../shared/drive-constraints'; import { isDriveValid, isSourceDrive } from '../../shared/drive-constraints';
import * as EXIT_CODES from '../../shared/exit-codes'; import * as EXIT_CODES from '../../shared/exit-codes';
import * as messages from '../../shared/messages'; import * as messages from '../../shared/messages';
import * as availableDrives from './models/available-drives'; import * as availableDrives from './models/available-drives';
import * as flashState from './models/flash-state'; import * as flashState from './models/flash-state';
import { init as ledsInit } from './models/leds'; import { init as ledsInit } from './models/leds';
import { deselectImage, getImage } from './models/selection-state'; import { deselectImage, getImage, selectDrive } from './models/selection-state';
import * as settings from './models/settings'; import * as settings from './models/settings';
import { Actions, observe, store } from './models/store'; import { Actions, observe, store } from './models/store';
import * as analytics from './modules/analytics'; import * as analytics from './modules/analytics';
@ -249,6 +249,14 @@ async function addDrive(drive: Drive) {
const drives = getDrives(); const drives = getDrives();
drives[preparedDrive.device] = preparedDrive; drives[preparedDrive.device] = preparedDrive;
setDrives(drives); 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) { function removeDrive(drive: Drive) {