[openstreetmap/openstreetmap-website] Introduce "reload" js controller method (PR #3774)

Tom Hughes notifications at github.com
Sun Oct 30 18:52:13 UTC 2022


@tomhughes commented on this pull request.



> @@ -179,8 +187,20 @@ OSM.Router = function (map, rts) {
   };
 
   router.load = function () {
-    var loadState = currentRoute.run("load", currentPath);
+    var loadState = loadOrReload();

What's the reason for putting this logic in a nested function if this is the only user?

>      router.stateChange(loadState || {});
+
+    function loadOrReload() {
+      if (currentRoute.has("reload") && window.performance) {
+        var wasReloaded = window.performance.getEntriesByType("navigation").some(function (entry) {
+          return entry.type === "reload";
+        });

I'm not familiar with `window.performance` but from a quick bit of reading on MDN it seems this if testing if there are any navigation events of type `reload` in the history but what's the scope of that? The comment you added says we're interest in whether this request was a reload?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3774#pullrequestreview-1161176853
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/3774/review/1161176853 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20221030/e6f5b529/attachment.htm>


More information about the rails-dev mailing list