Changeset 82079ad in Klonkt for src/middleware/render.js


Ignore:
Timestamp:
06/24/2026 12:31:43 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
3d7312a
Parents:
52ea6df
Message:

feat: one identity — user avatar falls back to the site photo everywhere

When a user has no own account avatar, display their site's profile photo across
the account page, top nav (render.js) and comments. No DB copy → stays in sync.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/middleware/render.js

    r52ea6df r82079ad  
    7373    const _fresh = db.prepare('SELECT avatar_url, role, lang FROM users WHERE id = ?').get(_u.id);
    7474    if (_fresh) _u = { ..._u, avatar_url: _fresh.avatar_url, role: _fresh.role, lang: _fresh.lang };
     75    // One identity: no own account avatar → fall back to the user's site photo,
     76    // so the same picture shows everywhere (nav, account, comments).
     77    if (_u && !_u.avatar_url) {
     78      const _sp = db.prepare("SELECT profile_photo FROM sites WHERE owner_id = ? AND profile_photo IS NOT NULL ORDER BY is_primary DESC, created_at ASC LIMIT 1").get(_u.id);
     79      if (_sp && _sp.profile_photo) _u = { ..._u, avatar_url: _sp.profile_photo };
     80    }
    7581  }
    7682  const userOwnsSite = !!(_u && _u.role !== 'god' &&
Note: See TracChangeset for help on using the changeset viewer.