Changeset 7881080 in Klonkt for src/services


Ignore:
Timestamp:
06/18/2026 03:28:34 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
8398935
Parents:
98ecf51
Message:

Hub #3: explicit is_primary flag + shared getPrimarySite() (DRY)

The "oldest site = primary site" assumption was duplicated independently in
resolveSite, hub.js, account.js and admin.js (fragile: if the oldest happened
to be an artist site, the hub home would be wrong). Now:

  • sites.is_primary column + backfill (marks the oldest if none is primary yet; ensurePrimarySite sets it on fresh installs) → existing behaviour exactly preserved.
  • one getPrimarySite() helper (is_primary, fallback oldest) replaces the 4 copies.
  • god can CHOOSE the primary/main site: ★ button + "primary" badge on /admin/sites (exactly one primary via a transaction).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ensurePrimarySite.js

    r98ecf51 r7881080  
    4040      language, palette, accent, profile_photo,
    4141      is_public, robots_index, require_login_to_comment, enable_audio_player,
    42       feed_view_default, comments_moderation_mode
    43     ) VALUES (?, ?, ?, '', '', ?, 'nl', 'sage', '#c2410c', NULL, 1, 1, 0, 1, 'grid', 'moderate')
     42      feed_view_default, comments_moderation_mode, is_primary
     43    ) VALUES (?, ?, ?, '', '', ?, 'nl', 'sage', '#c2410c', NULL, 1, 1, 0, 1, 'grid', 'moderate', 1)
    4444  `).run(siteId, slug, defaultTitle(), owner.id);
    4545
Note: See TracChangeset for help on using the changeset viewer.