File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -719,7 +719,9 @@ function sub_to_nearby_sondes(){
719719 // If we are fairly zooomed out - only give the slow feed
720720 for ( let i = 1 ; i < clientTopic . length ; i ++ ) { // skip first slow topic
721721 console . log ( "zoomed fully out. unsubbing from " + clientTopic [ i ] )
722- client . unsubscribe ( clientTopic [ i ] ) ;
722+ if ( client . isConnected ( ) ) {
723+ client . unsubscribe ( clientTopic [ i ] ) ;
724+ }
723725 }
724726 clientTopic = [ clientTopic [ 0 ] ]
725727 document . getElementById ( "zoom_warning" ) . style . display = "block"
@@ -732,13 +734,17 @@ function sub_to_nearby_sondes(){
732734 if ( inside_bounds ) {
733735 if ( ! clientTopic . includes ( topic ) ) {
734736 console . log ( "Subbing to " + topic )
735- client . subscribe ( topic ) ;
737+ if ( client . isConnected ( ) ) {
738+ client . subscribe ( topic ) ;
739+ }
736740 clientTopic . push ( topic )
737741 }
738742 } else {
739743 if ( clientTopic . includes ( topic ) ) {
740744 console . log ( "unsubbing from " + topic )
741- client . unsubscribe ( topic )
745+ if ( client . isConnected ( ) ) {
746+ client . unsubscribe ( topic )
747+ }
742748 var topic_index = clientTopic . indexOf ( topic )
743749 if ( topic_index > - 1 ) {
744750 clientTopic . splice ( topic_index , 1 ) ;
You can’t perform that action at this time.
0 commit comments