<p></p>
<p><b>@pablobm</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5968#discussion_r2398987514">app/assets/javascripts/leaflet.share.js</a>:</p>
<pre style='color:#555'>> + if (sessionStorage.getItem("wasAbleToAskForHandler")) return;
+ try {
+ navigator.registerProtocolHandler("geo", "/?geouri=%s");
+ sessionStorage.setItem("wasAbleToAskForHandler", "yes");
+ } catch (e) {
+ sessionStorage.setItem("wasAbleToAskForHandler", "no");
+ }
</pre>
<p dir="auto">How about this instead?</p>
<ul dir="auto">
<li>It avoids handling the success and error cases separately.</li>
<li>Uses a boolean instead of a "yes"/"no" string, which I think is more natural.</li>
<li>Uses a more specific name, just in case we want to ask for other handlers in the future.</li>
</ul>
⬇️ Suggested change
<pre style="color: #555">- if (sessionStorage.getItem("wasAbleToAskForHandler")) return;
- try {
- navigator.registerProtocolHandler("geo", "/?geouri=%s");
- sessionStorage.setItem("wasAbleToAskForHandler", "yes");
- } catch (e) {
- sessionStorage.setItem("wasAbleToAskForHandler", "no");
- }
+ if (sessionStorage.getItem("askedForGeoProtocolHandler")) return;
+ try {
+ navigator.registerProtocolHandler("geo", "/?geouri=%s");
+ } finally {
+ sessionStorage.setItem("askedForGeoProtocolHandler", true);
+ }
</pre>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5968#discussion_r2398988779">app/assets/javascripts/leaflet.share.js</a>:</p>
<pre style='color:#555'>> @@ -226,6 +228,16 @@ L.OSM.share = function (options) {
const precision = 5 * Math.pow(10, Math.floor(Math.LOG10E * Math.log(scale)) - 2);
return precision * Math.ceil(scale / precision);
}
+
+ function askToHandleGeoURI() {
+ if (sessionStorage.getItem("wasAbleToAskForHandler")) return;
+ try {
+ navigator.registerProtocolHandler("geo", "/?geouri=%s");
+ sessionStorage.setItem("wasAbleToAskForHandler", "yes");
+ } catch (e) {
+ sessionStorage.setItem("wasAbleToAskForHandler", "no");
</pre>
<p dir="auto">Sorry, I mean why use yes/no instead of a boolean. Hang on, I'm going to do an "add a suggestion" instead to illustrate... (Closing this thread and picking up in a new one).</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5968#pullrequestreview-3294854158">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLIFABGSCFEPGYEJQX33VUXJLAVCNFSM6AAAAAB4FA4A66VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTEOJUHA2TIMJVHA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJLQV4ZKYWVDQBIV6L3VUXJLA5CNFSM6AAAAAB4FA4A66WGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTWEMN6A4.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5968/review/3294854158</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5968#pullrequestreview-3294854158",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5968#pullrequestreview-3294854158",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>