only warm reload on the current page
change
commit 634173b8f9e8b96b30368cc6d98f8af9463366a4
author Alpha Chen <alpha@kejadlen.dev>
date
parent 590471a8
diff --git a/go_ji/templates/warm_reload.html b/go_ji/templates/warm_reload.html
index 9cb3dfe..e050143 100644
--- a/go_ji/templates/warm_reload.html
+++ b/go_ji/templates/warm_reload.html
@@ -1,7 +1,12 @@
 <script>
   const socket = new WebSocket('ws://' + location.host + '/warm-reload');
   const cb = ev => {
-    setTimeout(() => { window.location.reload(); }, 500);
+    const originalLocation = window.location.href;
+    setTimeout(() => {
+      if (window.location === originalLocation) {
+        window.location.reload();
+      }
+    }, 500);
   };
   socket.onerror = cb;
   socket.onclose = cb;