@@ -718,13 +718,17 @@ function sub_to_nearby_sondes(){
718718 let zoomed_out = map . getZoom ( ) <= 6 ;
719719 if ( zoomed_out ) {
720720 // If we are fairly zooomed out - only give the slow feed
721+ var newClientTopic = [ clientTopic [ 0 ] ]
721722 for ( let i = 1 ; i < clientTopic . length ; i ++ ) { // skip first slow topic
722- console . log ( "zoomed fully out. unsubbing from " + clientTopic [ i ] )
723- if ( client . isConnected ( ) ) {
723+ if ( client . isConnected ( ) && ! alwaysSub . includes ( clientTopic [ i ] . replace ( "sondes/" , "" ) ) ) {
724+ console . log ( "zoomed fully out. unsubbing from " + clientTopic [ i ] )
724725 client . unsubscribe ( clientTopic [ i ] ) ;
726+ } else {
727+ console . log ( "retaining " + clientTopic [ i ] ) ;
728+ newClientTopic . push ( clientTopic [ i ] )
725729 }
726730 }
727- clientTopic = [ clientTopic [ 0 ] ]
731+ clientTopic = newClientTopic
728732 document . getElementById ( "zoom_warning" ) . style . display = "block"
729733 } else {
730734 document . getElementById ( "zoom_warning" ) . style . display = "none"
@@ -741,14 +745,18 @@ function sub_to_nearby_sondes(){
741745 clientTopic . push ( topic )
742746 }
743747 } else {
744- if ( clientTopic . includes ( topic ) ) {
745- console . log ( "unsubbing from " + topic )
746- if ( client . isConnected ( ) ) {
747- client . unsubscribe ( topic )
748- }
749- var topic_index = clientTopic . indexOf ( topic )
750- if ( topic_index > - 1 ) {
751- clientTopic . splice ( topic_index , 1 ) ;
748+ if ( clientTopic . includes ( topic ) ) {
749+ if ( alwaysSub . includes ( vehicle ) ) {
750+ console . log ( "retaining " + vehicle )
751+ } else {
752+ console . log ( "unsubbing from " + topic )
753+ if ( client . isConnected ( ) ) {
754+ client . unsubscribe ( topic )
755+ }
756+ var topic_index = clientTopic . indexOf ( topic )
757+ if ( topic_index > - 1 ) {
758+ clientTopic . splice ( topic_index , 1 ) ;
759+ }
752760 }
753761 }
754762 }
@@ -1144,9 +1152,13 @@ function openURL(address){
11441152function panTo ( vcallsign ) {
11451153 if ( ! vcallsign || vehicles [ vcallsign ] === undefined ) return ;
11461154
1155+ alwaysSub . push ( vcallsign ) ;
1156+
11471157 for ( let serial in vehicles ) {
1148- vehicles [ serial ] . polyline_visible = false ;
1149- set_polyline_visibility ( serial , false ) ;
1158+ if ( ! alwaysSub . includes ( serial ) ) {
1159+ vehicles [ serial ] . polyline_visible = false ;
1160+ set_polyline_visibility ( serial , false ) ;
1161+ }
11501162 }
11511163 vehicles [ vcallsign ] . polyline_visible = true ;
11521164 set_polyline_visibility ( vcallsign , true ) ;
0 commit comments