File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -153,13 +153,20 @@ export const useDeviceStore = defineStore("device", {
153153 // biome-ignore lint/suspicious/noExplicitAny: FUGGEDABOUTIT
154154 connection . events . onDeviceMetadataPacket . subscribe ( ( packet : any ) => {
155155 // Try to find the device by pio env name first, then hw model if that fails
156- const device = this . targets . find (
157- ( target : DeviceHardware ) => target . platformioTarget === packet ?. data ?. platformioTarget ,
158- ) || this . targets . find (
159- ( target : DeviceHardware ) => target . hwModel === packet ?. data ?. hwModel ,
160- ) ;
161- console . log ( "Found device onDeviceMetadataPacket" , device ) ;
156+ let device = < undefined | DeviceHardware > undefined ;
157+ const targets = [ ...this . targets ] . sort ( ( a , b ) => a . hwModel - b . hwModel ) ;
158+ if ( packet ?. data ?. platformioTarget ?. length > 0 ) {
159+ device = targets . find (
160+ ( target : DeviceHardware ) => target . platformioTarget === packet ?. data ?. platformioTarget ,
161+ ) ;
162+ }
163+ if ( ! device ) {
164+ device = targets . find (
165+ ( target : DeviceHardware ) => target . hwModel === packet ?. data ?. hwModel ,
166+ ) ;
167+ }
162168 if ( device ) {
169+ console . log ( "Found device onDeviceMetadataPacket" , device ) ;
163170 this . setSelectedTarget ( device ) ;
164171 }
165172 } ) ;
You can’t perform that action at this time.
0 commit comments