CODEX - Added modal colours for the Bells

This commit is contained in:
2026-02-23 19:20:30 +02:00
parent a46e296dc3
commit cd218a55fe
6 changed files with 246 additions and 10 deletions

View File

@@ -10,7 +10,10 @@ def get_melody_settings() -> MelodySettings:
db = get_db()
doc = db.collection(COLLECTION).document(DOC_ID).get()
if doc.exists:
return MelodySettings(**doc.to_dict())
settings = MelodySettings(**doc.to_dict())
# Backfill newly introduced defaults into stored settings.
db.collection(COLLECTION).document(DOC_ID).set(settings.model_dump())
return settings
# Create with defaults
defaults = MelodySettings()
db.collection(COLLECTION).document(DOC_ID).set(defaults.model_dump())
@@ -35,5 +38,6 @@ def update_melody_settings(data: MelodySettingsUpdate) -> MelodySettings:
if "duration_values" in existing:
existing["duration_values"] = sorted(existing["duration_values"])
doc_ref.set(existing)
return MelodySettings(**existing)
normalized = MelodySettings(**existing)
doc_ref.set(normalized.model_dump())
return normalized