only warm reload on the current page
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;