diff --git a/lib/gui/app.js b/lib/gui/app.js index e4a8568d..f331bfea 100644 --- a/lib/gui/app.js +++ b/lib/gui/app.js @@ -38,6 +38,7 @@ const app = angular.module('Etcher', [ require('./models/selection-state'), require('./models/settings'), require('./models/supported-formats'), + require('./models/drives'), // Components require('./components/progress-button/progress-button'), @@ -87,6 +88,7 @@ app.controller('AppController', function( SelectionStateModel, SettingsModel, SupportedFormatsModel, + DrivesModel, ImageWriterService, AnalyticsService, DriveSelectorService, @@ -98,8 +100,8 @@ app.controller('AppController', function( let self = this; this.formats = SupportedFormatsModel; this.selection = SelectionStateModel; + this.drives = DrivesModel; this.writer = ImageWriterService; - this.scanner = DriveScannerService; this.settings = SettingsModel.data; this.success = true; @@ -142,7 +144,7 @@ app.controller('AppController', function( OSWindowProgressService.set(state.progress); }); - this.scanner.start(2000).on('error', OSDialogService.showError).on('scan', function(drives) { + DriveScannerService.start(2000).on('error', OSDialogService.showError).on('scan', function(drives) { // Cover the case where you select a drive, but then eject it. if (self.selection.hasDrive() && !_.find(drives, self.selection.isCurrentDrive)) { @@ -267,7 +269,7 @@ app.controller('AppController', function( // Stop scanning drives when flashing // otherwise Windows throws EPERM - self.scanner.stop(); + DriveScannerService.stop(); AnalyticsService.logEvent('Flash', { image: image, diff --git a/lib/gui/components/drive-selector/controllers/drive-selector.js b/lib/gui/components/drive-selector/controllers/drive-selector.js index 085aa5a5..493a21ef 100644 --- a/lib/gui/components/drive-selector/controllers/drive-selector.js +++ b/lib/gui/components/drive-selector/controllers/drive-selector.js @@ -18,7 +18,7 @@ const _ = require('lodash'); -module.exports = function($uibModalInstance, DriveScannerService, SelectionStateModel) { +module.exports = function($uibModalInstance, DrivesModel, SelectionStateModel) { /** * @summary The drive selector state @@ -28,7 +28,7 @@ module.exports = function($uibModalInstance, DriveScannerService, SelectionState this.state = SelectionStateModel; /** - * @summary The drive scanner service + * @summary The drives model * @property * @type Object * @@ -36,9 +36,9 @@ module.exports = function($uibModalInstance, DriveScannerService, SelectionState * We expose the whole service instead of the `.drives` * property, which is the one we're interested in since * this allows the property to be automatically updated - * when `DriveScannerService` detects a change in the drives. + * when `DrivesModel` detects a change in the drives. */ - this.scanner = DriveScannerService; + this.drives = DrivesModel; /** * @summary Close the modal and resolve the selected drive @@ -54,7 +54,7 @@ module.exports = function($uibModalInstance, DriveScannerService, SelectionState // Sanity check to cover the case where a drive is selected, // the drive is then unplugged from the computer and the modal // is resolved with a non-existent drive. - if (!selectedDrive || !_.includes(this.scanner.drives, selectedDrive)) { + if (!selectedDrive || !_.includes(this.drives.getDrives(), selectedDrive)) { return $uibModalInstance.dismiss(); } diff --git a/lib/gui/components/drive-selector/drive-selector.js b/lib/gui/components/drive-selector/drive-selector.js index c6831c10..873d40ef 100644 --- a/lib/gui/components/drive-selector/drive-selector.js +++ b/lib/gui/components/drive-selector/drive-selector.js @@ -24,7 +24,7 @@ const angular = require('angular'); const MODULE_NAME = 'Etcher.Components.DriveSelector'; const DriveSelector = angular.module(MODULE_NAME, [ require('angular-ui-bootstrap'), - require('../../modules/drive-scanner'), + require('../../models/drives'), require('../../models/selection-state'), require('../../utils/byte-size/byte-size') ]); diff --git a/lib/gui/components/drive-selector/templates/drive-selector-modal.tpl.html b/lib/gui/components/drive-selector/templates/drive-selector-modal.tpl.html index 311a693e..f8b83da6 100644 --- a/lib/gui/components/drive-selector/templates/drive-selector-modal.tpl.html +++ b/lib/gui/components/drive-selector/templates/drive-selector-modal.tpl.html @@ -5,7 +5,7 @@