From f799bae530c2463bcd67256107de430f12a05e9c Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 29 Apr 2022 12:11:49 +0900 Subject: [PATCH] front-end: Minor refactorings fixes --- front_end/src/yew_components.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front_end/src/yew_components.rs b/front_end/src/yew_components.rs index f305c42..b272934 100644 --- a/front_end/src/yew_components.rs +++ b/front_end/src/yew_components.rs @@ -605,9 +605,9 @@ impl Wrapper { } fn cleanup_disconnect_callbacks(&mut self) { - let window = web_sys::window().expect("Should be able to get window"); // if previously set disconnect callback is set, unset it if let Some(callback) = self.cleanup_id_callback.take() { + let window = web_sys::window().expect("Should be able to get window"); let mut options = EventListenerOptions::new(); options.capture(true); if window @@ -1288,6 +1288,7 @@ impl Component for Wrapper { if !self.do_backend_tick || !is_networked_multiplayer { // disconnect id if backend tick is to be stopped self.send_disconnect(); + self.cleanup_disconnect_callbacks(); return false; }