Changeset 7881080 in Klonkt for src/routes/hub.js


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/routes/hub.js

    r98ecf51 r7881080  
    3535  `).all();
    3636
    37   // De hoofd-/labelsite (oudste = de bedrijfs-/hoofdaccount) is GEEN artiest;
    38   // die tonen we apart bovenaan, niet in de Artiesten-roster.
     37  // De hoofd-/labelsite (de expliciet primaire = de bedrijfs-/hoofdaccount) is
     38  // GEEN artiest; die tonen we apart bovenaan, niet in de Artiesten-roster.
    3939  const mainSite = db.prepare(`
    4040    SELECT s.id, s.slug, s.title, s.tagline, s.profile_photo, s.accent,
     
    4343    FROM sites s
    4444    LEFT JOIN users u ON u.id = s.owner_id
    45     ORDER BY s.created_at ASC
     45    WHERE s.is_primary = 1
    4646    LIMIT 1
    4747  `).get() || null;
Note: See TracChangeset for help on using the changeset viewer.