Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
loading: Make the reload links work on a partially loaded page.
Aman Agrawal5b7f7d1b5045
diff --git a/templates/zerver/app/index.html b/templates/zerver/app/index.htmlindex 4ae020c088b..8308ba27345 100644--- a/templates/zerver/app/index.html+++ b/templates/zerver/app/index.html@@ -159,18 +159,18 @@ Accessing messages requires an account and Zulip API key.</div></div><div id="app-loading-bottom-content">- <p>{% trans %}If this message does not go away, try <a class="reload-lnk">reloading</a> the page.{% endtrans %}</p>+ <p>{% trans %}If this message does not go away, try <a class="reload-lnk" href="">reloading</a> the page.{% endtrans %}</p></div><div id="app-loading-error">- <p>{% trans %}Error loading Zulip. Try <a class="reload-lnk">reloading</a> the page.{% endtrans %}</p>+ <p>{% trans %}Error loading Zulip. Try <a class="reload-lnk" href="">reloading</a> the page.{% endtrans %}</p></div><script nonce="{{ csp_nonce }}">- document.addEventListener('DOMContentLoaded', function () {- function reload() {+ for (const lnk of document.querySelectorAll('.reload-lnk')) {+ lnk.addEventListener('click', function reload_keeping_hash(e) {+ e.preventDefault();window.location.reload(true);- }- document.querySelectorAll('.reload-lnk').forEach(lnk => lnk.addEventListener('click', reload));- });+ });+ }</script></div>diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.pyindex 5e860650e1f..f93b1dfa630 100644--- a/zerver/tests/test_home.py+++ b/zerver/tests/test_home.py@@ -324,6 +324,10 @@ class HomeTest(ZulipTestCase):if html_bit not in html:raise AssertionError(f"{html_bit} not in result")+ # Verify that the reload links work even if no JavaScript runs.+ self.assertIn('<a class="reload-lnk" href="">', html)+ self.assertNotIn('<a class="reload-lnk">', html)+page_params = self._get_page_params(result)self.assertCountEqual(page_params, self.expected_page_params_keys)