Skip to content

Commit

Permalink
Use normalizeMany
Browse files Browse the repository at this point in the history
  • Loading branch information
miikaah committed Jul 18, 2024
1 parent 2ba5cf7 commit 533668f
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,31 @@ export const createApi = async (
});

ipc.handle("normalizeMany", async (_, units: NormalizationUnit[]) => {
const result = await Normalization.normalize(
units[0].files.map(
(file) => `${musicLibraryPath}${decodeURI(new URL(file).pathname)}`,
),
);

return {
...result,
files: result.files.map((file) => ({
...file,
filepath: path.join(
electronFileProtocol,
file.filepath.replace(musicLibraryPath, ""),
const results = await Normalization.normalizeMany(
units.map((unit) => ({
...unit,
files: unit.files.map(
(file) => `${musicLibraryPath}${decodeURI(new URL(file).pathname)}`,
),
})),
};
);

return Object.entries(results).reduce(
(acc, [id, result]) => ({
...acc,
[id]: {
...result,
files: result.files.map((file) => ({
...file,
filepath: path.join(
electronFileProtocol,
file.filepath.replace(musicLibraryPath, ""),
),
})),
},
}),
{},
);
});

isInit = true;
Expand Down

0 comments on commit 533668f

Please sign in to comment.