@@ -22,7 +22,7 @@ import io from 'socket.io-client';
2222import semVerCompare from 'semver-compare' ;
2323import { detect } from 'detect-browser' ;
2424
25- import { BehaviorSubject , timer } from 'rxjs' ;
25+ import { timer } from 'rxjs' ;
2626import { filter , takeUntil , first } from 'rxjs/operators' ;
2727
2828import Daemon from './daemon' ;
@@ -52,26 +52,13 @@ if (browser.name !== 'chrome' && browser.name !== 'firefox') {
5252 orderedPluginAddresses = [ LOOPBACK_HOSTNAME , LOOPBACK_ADDRESS ] ;
5353}
5454
55- const DOWNLOAD_NOPE = 'DOWNLOAD_NOPE' ;
56- const DOWNLOAD_DONE = 'DOWNLOAD_DONE' ;
57- const DOWNLOAD_ERROR = 'DOWNLOAD_ERROR' ;
58- const DOWNLOAD_IN_PROGRESS = 'DOWNLOAD_IN_PROGRESS' ;
59-
6055export default class SocketDaemon extends Daemon {
6156 constructor ( ) {
6257 super ( ) ;
6358 this . selectedProtocol = PROTOCOL . HTTP ;
6459 this . socket = null ;
6560 this . pluginURL = null ;
6661
67- this . downloading = new BehaviorSubject ( { status : DOWNLOAD_NOPE } ) ;
68- this . downloadingDone = this . downloading . pipe ( filter ( download => download . status === DOWNLOAD_DONE ) )
69- . pipe ( first ( ) )
70- . pipe ( takeUntil ( this . downloading . pipe ( filter ( download => download . status === this . DOWNLOAD_ERROR ) ) ) ) ;
71- this . downloadingError = this . downloading . pipe ( filter ( download => download . status === DOWNLOAD_ERROR ) )
72- . pipe ( first ( ) )
73- . pipe ( takeUntil ( this . downloadingDone ) ) ;
74-
7562 this . openChannel ( ( ) => this . socket . emit ( 'command' , 'list' ) ) ;
7663
7764 this . agentFound
@@ -382,21 +369,21 @@ export default class SocketDaemon extends Daemon {
382369 }
383370
384371 handleDownloadMessage ( message ) {
385- if ( this . downloading . getValue ( ) . status !== DOWNLOAD_IN_PROGRESS ) {
372+ if ( this . downloading . getValue ( ) . status !== this . DOWNLOAD_IN_PROGRESS ) {
386373 return ;
387374 }
388375 switch ( message . DownloadStatus ) {
389376 case 'Pending' :
390- this . downloading . next ( { status : DOWNLOAD_IN_PROGRESS , msg : message . Msg } ) ;
377+ this . downloading . next ( { status : this . DOWNLOAD_IN_PROGRESS , msg : message . Msg } ) ;
391378 break ;
392379 case 'Success' :
393- this . downloading . next ( { status : DOWNLOAD_DONE , msg : message . Msg } ) ;
380+ this . downloading . next ( { status : this . DOWNLOAD_DONE , msg : message . Msg } ) ;
394381 break ;
395382 case 'Error' :
396- this . downloading . next ( { status : DOWNLOAD_ERROR , err : message . Msg } ) ;
383+ this . downloading . next ( { status : this . DOWNLOAD_ERROR , err : message . Msg } ) ;
397384 break ;
398385 default :
399- this . downloading . next ( { status : DOWNLOAD_IN_PROGRESS , msg : message . Msg } ) ;
386+ this . downloading . next ( { status : this . DOWNLOAD_IN_PROGRESS , msg : message . Msg } ) ;
400387 }
401388 }
402389
@@ -486,8 +473,8 @@ export default class SocketDaemon extends Daemon {
486473 * @param {string } packageName
487474 * @param {string } replacementStrategy
488475 */
489- downloadToolCommand ( toolName , toolVersion , packageName , replacementStrategy ) {
490- this . downloading . next ( { status : DOWNLOAD_IN_PROGRESS } ) ;
476+ downloadTool ( toolName , toolVersion , packageName , replacementStrategy ) {
477+ this . downloading . next ( { status : this . DOWNLOAD_IN_PROGRESS } ) ;
491478 this . socket . emit ( 'command' , `downloadtool ${ toolName } ${ toolVersion } ${ packageName } ${ replacementStrategy } ` ) ;
492479 }
493480
0 commit comments