Phase 2 UI Adjustments/Edits by bonamin

This commit is contained in:
2026-02-17 09:56:07 +02:00
parent 2b48426fe5
commit 59c5049305
16 changed files with 1588 additions and 609 deletions

View File

@@ -8,6 +8,13 @@ COLLECTION = "melodies"
def _doc_to_melody(doc) -> MelodyInDB:
"""Convert a Firestore document snapshot to a MelodyInDB model."""
data = doc.to_dict()
# Backward compat: if name/description are plain strings, wrap as dict
info = data.get("information", {})
if isinstance(info.get("name"), str):
info["name"] = {"en": info["name"]} if info["name"] else {}
if isinstance(info.get("description"), str):
info["description"] = {"en": info["description"]} if info["description"] else {}
data["information"] = info
return MelodyInDB(id=doc.id, **data)
@@ -41,8 +48,16 @@ def list_melodies(
continue
if search:
search_lower = search.lower()
name_match = search_lower in melody.information.name.lower()
desc_match = search_lower in melody.information.description.lower()
name_match = any(
search_lower in v.lower()
for v in melody.information.name.values()
if isinstance(v, str)
)
desc_match = any(
search_lower in v.lower()
for v in melody.information.description.values()
if isinstance(v, str)
)
tag_match = any(search_lower in t.lower() for t in melody.information.customTags)
if not (name_match or desc_match or tag_match):
continue