Skip to content

Commit 878a63f

Browse files
check net manager present
1 parent 7558c86 commit 878a63f

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

src/programs/taskbar_test.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,31 @@ export default {
8585
buttons.appendChild(mc_button);
8686
}
8787

88-
// add icon to reflect network status
89-
const net_manager = kernel.get_network_manager();
90-
const net_icon = document.createElement("span");
91-
net_icon.style.height = "3vh";
92-
net_icon.style.width = "3vh";
93-
net_icon.style.fontSize = "3vh";
94-
net_icon.style.display = "flex";
95-
net_icon.style.justifyContent = "center";
96-
net_icon.style.alignItems = "center";
97-
98-
const is_up = await net_manager.is_up();
99-
net_icon.style.color = is_up ? "green" : "red";
100-
net_icon.innerText = is_up ? "🌐︎" : "🔌︎";
101-
net_icon.title = is_up ? "Online" : "Offline";
102-
103-
// update when status changes
104-
process.network_add_manager_listener("state_change", (now_up) => {
105-
net_icon.style.color = now_up ? "green" : "red";
106-
net_icon.innerText = now_up ? "🌐︎" : "🔌︎";
107-
net_icon.title = now_up ? "Online" : "Offline";
108-
});
109-
110-
icons.appendChild(net_icon);
88+
if (kernel.has_network_manager()) {
89+
// add icon to reflect network status
90+
const net_manager = kernel.get_network_manager();
91+
const net_icon = document.createElement("span");
92+
net_icon.style.height = "3vh";
93+
net_icon.style.width = "3vh";
94+
net_icon.style.fontSize = "3vh";
95+
net_icon.style.display = "flex";
96+
net_icon.style.justifyContent = "center";
97+
net_icon.style.alignItems = "center";
98+
99+
const is_up = await net_manager.is_up();
100+
net_icon.style.color = is_up ? "green" : "red";
101+
net_icon.innerText = is_up ? "🌐︎" : "🔌︎";
102+
net_icon.title = is_up ? "Online" : "Offline";
103+
104+
// update when status changes
105+
process.network_add_manager_listener("state_change", (now_up) => {
106+
net_icon.style.color = now_up ? "green" : "red";
107+
net_icon.innerText = now_up ? "🌐︎" : "🔌︎";
108+
net_icon.title = now_up ? "Online" : "Offline";
109+
});
110+
111+
icons.appendChild(net_icon);
112+
}
111113

112114
wind.show();
113115

0 commit comments

Comments
 (0)