Skip to content

Commit

Permalink
fix: improve track filtering logic in album import
Browse files Browse the repository at this point in the history
need to filter after matching recordings to works

fixes #52
  • Loading branch information
dvirtz committed Jan 14, 2025
1 parent 8a3bc18 commit 4facf54
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/acum-work-import/import-album.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import {
filter,
from,
ignoreElements,
iif,
lastValueFrom,
map,
merge,
mergeMap,
of,
pipe,
repeat,
scan,
tap,
toArray,
Expand Down Expand Up @@ -168,12 +170,12 @@ async function selectedRecordings(
from(medium.tracks!.map(track => trackRecordingState(track, recordingStateTree)))
);
}),
filter((trackAndRecordingState): trackAndRecordingState is [number, MediumRecordingStateT] => {
const [, recordingState] = trackAndRecordingState;
zipWith(iif(() => entity == Entity.Work, from(workBeans).pipe(repeat()), from(workBeans))),
map(([[position, recordingState], workBean]) => [position, workBean, recordingState] as const),
filter((state): state is [number, WorkBean, MediumRecordingStateT] => {
const [, , recordingState] = state;
return recordingState != null && (noSelection || recordingState.isSelected);
}),
zipWith(from(workBeans)),
map(([[position, recordingState], workBean]) => [position, workBean, recordingState] as const),
toArray()
)
);
Expand Down

0 comments on commit 4facf54

Please sign in to comment.