Skip to content

Commit

Permalink
fix: clearer error reporting
Browse files Browse the repository at this point in the history
report processing is done
don't report all works are up to date
  • Loading branch information
dvirtz committed Jan 17, 2025
1 parent 81b7f8e commit 3bd3d1b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
51 changes: 30 additions & 21 deletions src/acum-work-import/import-album.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,38 @@ async function importSelectedWorks(
const artistCache: ArtistCache = new Map();

return await lastValueFrom(
from(selectedRecordings).pipe(
map(([position, workBean, recordingState]) => [workBean, recordingState, addTrackWarning(position)] as const),
tap(([workBean, recordingState, addWarning]) => {
const recording = recordingState.recording;
if (trackName(workBean) != recording.name) {
if (compareInsensitive(trackName(workBean), recording.name) === 0) {
workBean.workEngName = workBean.workHebName = recording.name;
} else {
addWarning(`Work name of ${recording.name} is different from recording name, please verify`);
iif(
() => selectedRecordings.length > 0,
from(selectedRecordings).pipe(
map(([position, workBean, recordingState]) => [workBean, recordingState, addTrackWarning(position)] as const),
tap(([workBean, recordingState, addWarning]) => {
const recording = recordingState.recording;
if (trackName(workBean) != recording.name) {
if (compareInsensitive(trackName(workBean), recording.name) === 0) {
workBean.workEngName = workBean.workHebName = recording.name;
} else {
addWarning(`Work name of ${recording.name} is different from recording name, please verify`);
}
}
}
}),
mergeMap(
async ([workBean, recordingState, addWarning]) =>
[workBean, recordingState.recording, await addWork(workBean, recordingState, addWarning), addWarning] as const
),
mergeMap(args => linkCreators(artistCache, ...args)),
connect(shared =>
merge(
shared.pipe(maybeSetEditNote(entity, addWarning)),
shared.pipe(updateProgress(selectedRecordings, setProgress), ignoreElements())
}),
mergeMap(
async ([workBean, recordingState, addWarning]) =>
[
workBean,
recordingState.recording,
await addWork(workBean, recordingState, addWarning),
addWarning,
] as const
),
mergeMap(args => linkCreators(artistCache, ...args)),
connect(shared =>
merge(
shared.pipe(maybeSetEditNote(entity, addWarning)),
shared.pipe(updateProgress(selectedRecordings, setProgress), ignoreElements())
)
)
)
),
from(selectedRecordings).pipe(updateProgress(selectedRecordings, setProgress), ignoreElements(), endWith(false))
)
);
}
Expand Down
3 changes: 1 addition & 2 deletions src/acum-work-import/ui/release-editor-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ function AcumImporter() {
async function importWorks(entity: Entity) {
clearWarnings();
try {
await tryImportWorks(entity, addWarning, setProgress);
setWorksPending(true);
setWorksPending(await tryImportWorks(entity, addWarning, setProgress));
} catch (err) {
console.error(err);
addWarning(`Import failed: ${String(err)}`);
Expand Down

0 comments on commit 3bd3d1b

Please sign in to comment.