@@ -22,7 +22,7 @@ import io from 'socket.io-client';
22
22
import semVerCompare from 'semver-compare' ;
23
23
import { detect } from 'detect-browser' ;
24
24
25
- import { BehaviorSubject , timer } from 'rxjs' ;
25
+ import { timer } from 'rxjs' ;
26
26
import { filter , takeUntil , first } from 'rxjs/operators' ;
27
27
28
28
import Daemon from './daemon' ;
@@ -52,26 +52,13 @@ if (browser.name !== 'chrome' && browser.name !== 'firefox') {
52
52
orderedPluginAddresses = [ LOOPBACK_HOSTNAME , LOOPBACK_ADDRESS ] ;
53
53
}
54
54
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
-
60
55
export default class SocketDaemon extends Daemon {
61
56
constructor ( ) {
62
57
super ( ) ;
63
58
this . selectedProtocol = PROTOCOL . HTTP ;
64
59
this . socket = null ;
65
60
this . pluginURL = null ;
66
61
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
-
75
62
this . openChannel ( ( ) => this . socket . emit ( 'command' , 'list' ) ) ;
76
63
77
64
this . agentFound
@@ -382,21 +369,21 @@ export default class SocketDaemon extends Daemon {
382
369
}
383
370
384
371
handleDownloadMessage ( message ) {
385
- if ( this . downloading . getValue ( ) . status !== DOWNLOAD_IN_PROGRESS ) {
372
+ if ( this . downloading . getValue ( ) . status !== this . DOWNLOAD_IN_PROGRESS ) {
386
373
return ;
387
374
}
388
375
switch ( message . DownloadStatus ) {
389
376
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 } ) ;
391
378
break ;
392
379
case 'Success' :
393
- this . downloading . next ( { status : DOWNLOAD_DONE , msg : message . Msg } ) ;
380
+ this . downloading . next ( { status : this . DOWNLOAD_DONE , msg : message . Msg } ) ;
394
381
break ;
395
382
case 'Error' :
396
- this . downloading . next ( { status : DOWNLOAD_ERROR , err : message . Msg } ) ;
383
+ this . downloading . next ( { status : this . DOWNLOAD_ERROR , err : message . Msg } ) ;
397
384
break ;
398
385
default :
399
- this . downloading . next ( { status : DOWNLOAD_IN_PROGRESS , msg : message . Msg } ) ;
386
+ this . downloading . next ( { status : this . DOWNLOAD_IN_PROGRESS , msg : message . Msg } ) ;
400
387
}
401
388
}
402
389
@@ -486,8 +473,8 @@ export default class SocketDaemon extends Daemon {
486
473
* @param {string } packageName
487
474
* @param {string } replacementStrategy
488
475
*/
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 } ) ;
491
478
this . socket . emit ( 'command' , `downloadtool ${ toolName } ${ toolVersion } ${ packageName } ${ replacementStrategy } ` ) ;
492
479
}
493
480
0 commit comments