source: Klonkt/src/services/SettingsService.js@ cbcc8a4

main
Last change on this file since cbcc8a4 was dd856db, checked in by Robin Genis <roboburr@…>, 3 months ago

Remove hub mode (step 1/2): keystone coercion + drop hub UI

getTenancy() now only returns 'solo'|'circle' (legacy 'hub' -> 'solo'), so every
tenancy==='hub' branch is unreachable. Removed the Hub tenancy radio + hub-home
branding form from settings, and the dead hub premium gate. Solo + Circle paths
unchanged. Dead hub code (hub.js, artists.js, hub-home view, /user routing, etc.)
gets deleted in step 2.

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

  • Property mode set to 100644
File size: 1.6 KB
Line 
1// Global app settings (key/value, cached). Primarily used for the tenancy mode.
2//
3// tenancy = 'solo' -> exactly one site (the primary/owner site)
4// tenancy = 'circle' -> solo site that federates with other solo Klonkt sites
5//
6// HUB MODE IS REMOVED (2026-06-24): multi-artist-per-domain was dropped in favour
7// of solo + Cirkels. getTenancy() coerces any legacy 'hub' value to 'solo' so all
8// the old `tenancy === 'hub'` branches are unreachable; the hub code is being
9// deleted incrementally.
10//
11// The cache is updated immediately on setSetting, so a toggle in admin
12// takes effect live without a restart.
13
14import db from '../config/database.js';
15
16let _cache = null;
17
18function load() {
19 if (!_cache) {
20 _cache = {};
21 for (const r of db.prepare('SELECT key, value FROM app_settings').all()) {
22 _cache[r.key] = r.value;
23 }
24 }
25 return _cache;
26}
27
28export function getSetting(key, fallback = null) {
29 const v = load()[key];
30 return v === undefined ? fallback : v;
31}
32
33export function setSetting(key, value) {
34 db.prepare(`
35 INSERT INTO app_settings (key, value, updated_at) VALUES (?, ?, CURRENT_TIMESTAMP)
36 ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = CURRENT_TIMESTAMP
37 `).run(key, String(value));
38 if (_cache) _cache[key] = String(value);
39}
40
41export function getTenancy() {
42 const v = getSetting('tenancy', 'solo');
43 // 'hub' is removed → coerce legacy values to 'solo'.
44 return v === 'circle' ? 'circle' : 'solo';
45}
46
47export function setTenancy(mode) {
48 const m = mode === 'circle' ? 'circle' : 'solo';
49 setSetting('tenancy', m);
50}
Note: See TracBrowser for help on using the repository browser.