]> git.seodisparate.com - EN605.607.81.SP22_ASDM_Project/commitdiff
front-end: Minor refactorings fixes
authorStephen Seo <seo.disparate@gmail.com>
Fri, 29 Apr 2022 03:11:49 +0000 (12:11 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 29 Apr 2022 03:12:01 +0000 (12:12 +0900)
front_end/src/yew_components.rs

index f305c42c7b8c3ae0c21234f7c0569ce7ed8271c6..b272934d37c9ab411f45394ac80c035bff85a91f 100644 (file)
@@ -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;
                 }