<h2 dir="auto">Add User Preferences Support to iD Editor</h2>
<h3 dir="auto">Summary</h3>
<p dir="auto">This PR implements server-side rendering of user preferences for the iD editor, making them accessible in the client-side JavaScript context.</p>
<h3 dir="auto">Technical Changes</h3>
<p dir="auto"><strong>Server-side (<code class="notranslate">app/views/site/id.html.erb</code>):</strong></p>
<ul dir="auto">
<li>Added user preference collection logic that fetches all preferences for the current user</li>
<li>Converts preferences from ActiveRecord objects to a hash structure (<code class="notranslate">{key => value}</code>)</li>
<li>Serializes preferences as JSON and includes them in the data attributes passed to the iD container</li>
</ul>
<p dir="auto"><strong>Client-side (<code class="notranslate">app/assets/javascripts/id.js</code>):</strong></p>
<ul dir="auto">
<li>Added preference parsing logic that extracts user preferences from the container's dataset</li>
<li>Parses JSON-encoded preferences and makes them available globally via <code class="notranslate">window.OSM.userPreferences</code></li>
<li>Provides fallback to empty object for unauthenticated users or users without preferences</li>
</ul>
<h3 dir="auto">Implementation Details</h3>
<ul dir="auto">
<li>Follows existing pattern used for other iD editor data (token, locale, asset_map)</li>
<li>User preferences are fetched via <code class="notranslate">current_user.preferences.each_with_object({})</code> for efficient hash construction</li>
<li>Data flow: Database → Ruby hash → JSON string → HTML data attribute → JavaScript object</li>
<li>Preferences are only included when <code class="notranslate">current_user</code> exists (authenticated users)</li>
<li>Client-side code gracefully handles missing or malformed preference data</li>
</ul>
<h3 dir="auto">Use Case</h3>
<p dir="auto">This enables the iD editor to access user-specific preferences (such as display settings, editor configurations, etc.) that were previously only available through separate API calls, improving performance and reducing client-server round trips during editor initialization.</p>
<h3 dir="auto">Testing</h3>
<ul dir="auto">
<li>Verified with authenticated users having preferences</li>
<li>Verified with authenticated users having no preferences</li>
<li>Verified with unauthenticated users</li>
<li>Confirmed preferences are accessible via <code class="notranslate">window.OSM.userPreferences</code> in browser console</li>
</ul>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/openstreetmap/openstreetmap-website/pull/6199'>https://github.com/openstreetmap/openstreetmap-website/pull/6199</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/6199/commits/762d69c5878411774aad58293a55c10c1e352ca0" class="commit-link">762d69c</a>  Add user preferences support to iD editor via server-side rendering</li>
</ul>

<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/6199/files">2 files</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6199/files#diff-e37bc574e30721f9d7464e669f8c8224398df640a8b215071b41ee3803fc6eaf">app/assets/javascripts/id.js</a>
    (9)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6199/files#diff-04b315da745cedb77066ff53c411bc4f0630989c735a470f8e23a9ade696a80c">app/views/site/id.html.erb</a>
    (10)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/6199.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/6199.patch</a></li>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/6199.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/6199.diff</a></li>
</ul>

<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/6199">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLLZNQFK6VGFR5EJMW33IXPKZAVCNFSM6AAAAACBTZ6EP6VHI2DSMVQWIX3LMV43ASLTON2WKOZTGIZTINJSGMZDCMA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLMJR3VO65IN24C5CID3IXPKZA5CNFSM6AAAAACBTZ6EP6WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHMBSXIJI.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/6199</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/6199",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/6199",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>