mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Improved drag to import dialog
This commit is contained in:
1 parent
bf427a628e
commit
518542c7bb
15 files changed
+180
-35
No files matched your search
@@ -317,6 +317,7 @@ def run(
|
||||
folder_name: str | None = None,
|
||||
reference: bool = False,
|
||||
into_playlist: str | None = None,
|
||||
into_playlist_index: int | None = None,
|
||||
) -> dict:
|
||||
"""Perform the import. Returns a summary dict for the job result.
|
||||
|
||||
@@ -332,7 +333,8 @@ def run(
|
||||
`reference` adds each file WHERE IT IS instead of copying it, so there is no
|
||||
destination and nothing to roll back. `into_playlist` appends every planned
|
||||
track — the new ones and those the destination already held — to one of the
|
||||
destination's playlists before the save, so both land in one commit.
|
||||
destination's playlists before the save, so both land in one commit;
|
||||
`into_playlist_index` inserts them there instead (a drop between rows).
|
||||
|
||||
A destination that PLACES ITS OWN AUDIO (`tracks.places_audio`: a OneLibrary
|
||||
stick) overrides both: `dest.place_audio` names each copy's target, or says
|
||||
@@ -446,9 +448,9 @@ def run(
|
||||
handle.progress(message="Adding to the playlist…")
|
||||
current = dest.playlist_entries(into_playlist) or []
|
||||
have = set(current)
|
||||
dest.set_playlist_entries(
|
||||
into_playlist, current + [i for i in all_ids if i not in have]
|
||||
)
|
||||
fresh = [i for i in all_ids if i not in have]
|
||||
at = len(current) if into_playlist_index is None else max(0, min(len(current), into_playlist_index))
|
||||
dest.set_playlist_entries(into_playlist, current[:at] + fresh + current[at:])
|
||||
|
||||
playlists_made = _rebuild_playlists(
|
||||
source, dest, plan, by_source, folder_name, handle
|
||||
|
||||
@@ -1309,7 +1309,8 @@ def add_entries(playlist_uuid: str, body: AddEntries) -> dict:
|
||||
return {"status": "duplicates", "id": playlist_uuid, "added": 0,
|
||||
"duplicates": len(dupes), "count": len(current)}
|
||||
added = list(body.track_ids) if mode == "add" else [t for t in body.track_ids if t not in have]
|
||||
n = a.set_playlist_entries(playlist_uuid, current + added) if added else len(current)
|
||||
at = len(current) if body.index is None else max(0, min(len(current), body.index))
|
||||
n = a.set_playlist_entries(playlist_uuid, current[:at] + added + current[at:]) if added else len(current)
|
||||
return {"status": "added", "id": playlist_uuid, "added": len(added),
|
||||
"duplicates": len(dupes), "count": n}
|
||||
|
||||
@@ -2572,6 +2573,7 @@ def folder_add(body: FolderAddRequest) -> JobStatus:
|
||||
source, dest, plan, handle,
|
||||
reference=in_place or body.mode == "reference",
|
||||
into_playlist=body.playlist_id,
|
||||
into_playlist_index=body.playlist_index,
|
||||
)
|
||||
# Export sets are Konduktor's own data, not the library's, so they are
|
||||
# updated after the library has been saved rather than inside it.
|
||||
@@ -2658,6 +2660,7 @@ def start_import(body: ImportRequest) -> JobStatus:
|
||||
def work(handle):
|
||||
result = importer.run(
|
||||
source, dest, plan, handle, folder_name=folder_name, into_playlist=body.into_playlist,
|
||||
into_playlist_index=body.into_playlist_index,
|
||||
)
|
||||
# As folder add: an export set is Konduktor's data, updated afterwards.
|
||||
if body.export_id is not None and library is not None:
|
||||
|
||||
@@ -27,6 +27,9 @@ class AddEntries(BaseModel):
|
||||
# where `playlists.duplicates`, else skipped), or "ask" — change nothing and
|
||||
# report how many, so the UI can ask and send again with skip/add.
|
||||
duplicates: Literal["skip", "add", "ask"] = "skip"
|
||||
# Insert at this position among the playlist's CURRENT entries (a drop
|
||||
# between rows); None appends. Clamped to the list.
|
||||
index: int | None = None
|
||||
|
||||
|
||||
class MovePlaylist(BaseModel):
|
||||
@@ -545,6 +548,7 @@ class ImportRequest(BaseModel):
|
||||
# drop): every imported track — and every one the collection already
|
||||
# holds — goes into it, as folder add does.
|
||||
into_playlist: str | None = None
|
||||
into_playlist_index: int | None = None # where in it (see AddEntries.index)
|
||||
export_id: str | None = None
|
||||
|
||||
|
||||
@@ -613,6 +617,7 @@ class FolderAddRequest(BaseModel):
|
||||
mode: Literal["copy", "reference"]
|
||||
destination: str | None = None # required for `copy`
|
||||
playlist_id: str | None = None
|
||||
playlist_index: int | None = None # where in it (see AddEntries.index)
|
||||
export_id: str | None = None
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user