Skip to content

Commit aea184d

Browse files
authored
fix: finishing packet sending when packet is selected (#48)
An error is thrown when a packet’s sending process ends with the packet being selected. The error was resolved by deselecting the packet once its sending process is complete.
1 parent 8d89b79 commit aea184d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/types/packet.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Ticker,
66
} from "pixi.js";
77
import { Edge, Position } from "./edge";
8-
import { selectElement } from "./viewportManager";
8+
import { deselectElement, isSelected, selectElement } from "./viewportManager";
99
import { circleGraphicsContext, Colors, ZIndexLevels } from "../utils";
1010
import { RightBar } from "../index";
1111

@@ -116,6 +116,9 @@ export class Packet extends Graphics {
116116
this.removeFromParent();
117117
if (this.currentPath.length == 0) {
118118
ticker.remove(this.animationTick, this);
119+
if (isSelected(this)) {
120+
deselectElement();
121+
}
119122
this.destroy();
120123
return;
121124
}

src/types/viewportManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export function refreshElement() {
3535
}
3636
}
3737

38+
export function isSelected(element: Device | Edge | Packet) {
39+
return element === selectedElement;
40+
}
41+
3842
document.addEventListener("keydown", (event) => {
3943
if (event.key === "Delete" || event.key === "Backspace") {
4044
if (selectedElement) {

0 commit comments

Comments
 (0)