Bedre sync
This commit is contained in:
@@ -76,7 +76,7 @@ class PushPayload(BaseModel):
|
||||
song_dances: list[SongDanceData] = []
|
||||
song_alts: list[SongAltDanceData] = []
|
||||
playlists: list[PlaylistData] = []
|
||||
deleted_playlists: list[str] = [] # navne på slettede playlister
|
||||
deleted_playlists: list[str] = [] # server-IDs (api_project_id) på slettede playlister
|
||||
|
||||
|
||||
# ── Push ──────────────────────────────────────────────────────────────────────
|
||||
@@ -241,8 +241,9 @@ def push(
|
||||
db.add(proj_song)
|
||||
|
||||
# ── Slet playlister der er fjernet lokalt ─────────────────────────────────
|
||||
for name in payload.deleted_playlists:
|
||||
proj = db.query(Project).filter_by(owner_id=me.id, name=name).first()
|
||||
# Klienten sender api_project_id (= server Project.id) som strings
|
||||
for project_id in payload.deleted_playlists:
|
||||
proj = db.query(Project).filter_by(id=project_id, owner_id=me.id).first()
|
||||
if proj:
|
||||
db.query(ProjectSong).filter_by(project_id=proj.id).delete()
|
||||
db.delete(proj)
|
||||
@@ -378,4 +379,4 @@ def pull(
|
||||
"shared": shared,
|
||||
"my_playlists": my_playlists,
|
||||
"song_tags": song_tags,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user