1- import { BehaviorSubject } from 'rxjs' ;
1+ import { BehaviorSubject } from 'rxjs' ;
22
33import {
44 takeUntil ,
@@ -41,15 +41,15 @@ export default class FirmwareUpdater {
4141
4242 this . FWUToolStatus = FWUToolStatusEnum . NOPE ;
4343 this . updating = new BehaviorSubject ( { status : this . updateStatusEnum . NOPE } ) ;
44-
44+
4545 this . updatingDone = this . updating . pipe ( filter ( update => update . status === this . updateStatusEnum . DONE ) )
4646 . pipe ( first ( ) )
4747 . pipe ( takeUntil ( this . updating . pipe ( filter ( update => update . status === this . updateStatusEnum . ERROR ) ) ) ) ;
48-
48+
4949 this . updatingError = this . updating . pipe ( filter ( update => update . status === this . updateStatusEnum . ERROR ) )
5050 . pipe ( first ( ) )
5151 . pipe ( takeUntil ( this . updatingDone ) ) ;
52-
52+
5353 this . gotFWInfo = this . updating . pipe ( filter ( update => update . status === this . updateStatusEnum . GOT_INFO ) )
5454 . pipe ( first ( ) )
5555 . pipe ( takeUntil ( this . updatingDone ) )
@@ -64,14 +64,15 @@ export default class FirmwareUpdater {
6464 let firmwareInfoMessagesSubscription ;
6565
6666 const handleFirmwareInfoMessage = message => {
67+ let versions ;
6768 switch ( message . ProgrammerStatus ) {
6869 case 'Starting' :
6970 break ;
7071 case 'Busy' :
7172 if ( message . Msg . indexOf ( 'Flashing with command:' ) >= 0 ) {
7273 return ;
7374 }
74- const versions = JSON . parse ( message . Msg ) ;
75+ versions = JSON . parse ( message . Msg ) ;
7576 Object . keys ( versions ) . forEach ( v => {
7677 if ( versions [ v ] [ 0 ] . IsLoader ) {
7778 this . loaderPath = versions [ v ] [ 0 ] . Path ;
@@ -83,7 +84,6 @@ export default class FirmwareUpdater {
8384 this . firmwareVersionData = versionsList . find ( version => version . Name . split ( ' ' ) . splice ( - 1 ) [ 0 ] . trim ( ) === firmwareVersion ) ;
8485 if ( ! this . firmwareVersionData ) {
8586 this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Can't get firmware info: couldn't find version '${ firmwareVersion } ' for board '${ boardId } '` } ) ;
86- return ;
8787 }
8888 break ;
8989 case 'Error' :
@@ -97,8 +97,8 @@ export default class FirmwareUpdater {
9797 default :
9898 break ;
9999 }
100- }
101-
100+ } ;
101+
102102 if ( this . FWUToolStatus !== FWUToolStatusEnum . OK ) {
103103 this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Can't get firmware info: couldn't find firmware updater tool` } ) ;
104104 return ;
@@ -131,12 +131,12 @@ export default class FirmwareUpdater {
131131 } ) . then ( response => {
132132 if ( ! response . ok ) {
133133 this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Error fetching ${ this . Daemon . pluginURL } /upload` } ) ;
134- return ;
134+
135135 }
136- } ) . catch ( reason => {
136+ } ) . catch ( ( ) => {
137137 this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Coudln't list firmware versions info.` } ) ;
138- return ;
139- } ) ;
138+
139+ } ) ;
140140 }
141141
142142 updateFirmware ( boardId , port , firmwareVersion ) {
@@ -147,28 +147,28 @@ export default class FirmwareUpdater {
147147 this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Can't update Firmware: no port selected.` } ) ;
148148 return ;
149149 }
150- this . gotFWInfo . subscribe ( state => {
150+ this . gotFWInfo . subscribe ( ( ) => {
151151 if ( ! this . firmwareVersionData ) {
152152 this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Can't update Firmware: couldn't find version '${ firmwareVersion } ' for board '${ boardId } '` } ) ;
153153 return ;
154154 }
155155
156156 let updateFirmwareMessagesSubscription ;
157-
157+
158158 const handleFirmwareUpdateMessage = message => {
159159 switch ( message . ProgrammerStatus ) {
160160 case 'Error' :
161- this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Can't update Firmware: ${ message . Msg } ` } ) ;
161+ this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Can't update Firmware: ${ message . Msg } ` } ) ;
162162 updateFirmwareMessagesSubscription . unsubscribe ( ) ;
163163 break ;
164164 case 'Done' :
165- this . updating . next ( { status : this . updateStatusEnum . DONE } ) ;
165+ this . updating . next ( { status : this . updateStatusEnum . DONE } ) ;
166166 updateFirmwareMessagesSubscription . unsubscribe ( ) ;
167167 break ;
168168 default :
169169 break ;
170170 }
171- }
171+ } ;
172172
173173 updateFirmwareMessagesSubscription = this . Daemon . appMessages . subscribe ( message => {
174174 if ( message . ProgrammerStatus ) {
@@ -181,7 +181,7 @@ export default class FirmwareUpdater {
181181 domain : 'arduino.cc' ,
182182 port : 443
183183 } ] ;
184-
184+
185185 rootCertificates . forEach ( address => {
186186 if ( address . domain && address . port ) {
187187 addresses += `-address ${ address . domain } :${ address . port } ` ;
@@ -221,11 +221,11 @@ export default class FirmwareUpdater {
221221 } ) . then ( response => {
222222 if ( ! response . ok ) {
223223 this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Can't update Firmware: error fetching ${ this . Daemon . pluginURL } /upload` } ) ;
224- return ;
224+
225225 }
226226 } ) . catch ( reason => {
227227 this . updating . next ( { status : this . updateStatusEnum . ERROR , err : `Can't update Firmware: ${ reason } ` } ) ;
228- return ;
228+
229229 } ) ;
230230 } ) ;
231231 this . getFirmwareInfo ( boardId , port , firmwareVersion ) ;
0 commit comments