File tree Expand file tree Collapse file tree 4 files changed +18
-7
lines changed
Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,10 @@ export class GlobalContext {
5151 private setNetwork ( datagraph : DataGraph , layer : Layer ) {
5252 this . datagraph = datagraph ;
5353 if ( this . viewgraph ) {
54- this . viewgraph . setDataGraph ( datagraph ) ;
55- this . viewgraph . changeCurrLayer ( layer ) ;
56- } else {
57- this . viewgraph = new ViewGraph ( datagraph , this , layer ) ;
54+ this . viewgraph . clearPacketsInTransit ( ) ;
55+ this . viewgraph . clear ( ) ;
5856 }
57+ this . viewgraph = new ViewGraph ( datagraph , this , layer ) ;
5958 this . setIpGenerator ( ) ;
6059 this . setMacGenerator ( ) ;
6160 }
@@ -106,9 +105,9 @@ export class GlobalContext {
106105 return this . datagraph ;
107106 }
108107
109- changeViewGraph ( selectedLayer : string ) {
108+ changeLayer ( selectedLayer : string ) {
110109 const layer = layerFromName ( selectedLayer ) ;
111- this . setNetwork ( this . datagraph , layer ) ;
110+ this . viewgraph . changeCurrLayer ( layer ) ;
112111 }
113112
114113 pause ( ) {
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ export class LayerHandler {
6464 }
6565
6666 console . debug ( `Layer selected: ${ selectedLayer } ` ) ;
67- this . ctx . changeViewGraph ( selectedLayer ) ;
67+ this . ctx . changeLayer ( selectedLayer ) ;
6868 saveToLocalStorage ( this . ctx ) ;
6969 this . leftBar . setButtonsByLayer ( selectedLayer ) ;
7070 deselectElement ( ) ;
Original file line number Diff line number Diff line change @@ -338,6 +338,10 @@ export class ViewGraph {
338338 } ) ;
339339 }
340340
341+ clearPacketsInTransit ( ) {
342+ this . packetManager . clear ( ) ;
343+ }
344+
341345 hasDevice ( id : DeviceId ) {
342346 return this . graph . hasVertex ( id ) ;
343347 }
Original file line number Diff line number Diff line change @@ -21,6 +21,14 @@ export class PacketManager {
2121 this . packetsInTransit . delete ( packetId ) ;
2222 }
2323
24+ /**
25+ * Deletes each packet in transit.
26+ */
27+ clear ( ) {
28+ const packetsInTransit = Array . from ( this . packetsInTransit . values ( ) ) ;
29+ packetsInTransit . forEach ( ( packet ) => packet . delete ( ) ) ;
30+ }
31+
2432 // SE CAMBIA CAPA (borrar luego)
2533 // va paquete por paquete
2634 // se fija si el paquete corresponde a la nueva capa (es visible o no)
You can’t perform that action at this time.
0 commit comments