Skip to content

Commit

Permalink
fix: Moving starred images could result in only 1 page showing after.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrseanryan committed Dec 30, 2018
1 parent f13fc91 commit dff28d3
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/electronApp/rendering/MovedStarredImagesRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ export namespace MoveStarredImagesRenderer {
let hasErrors = false;

return new Promise<void>((resolve, reject) => {
imagePaths.forEach(imagePath => {
const done = () => {
if (hasErrors) {
reject("Some errors occurred when moving the files");
} else {
resolve();
}
};

imagePaths.forEach((imagePath, index) => {
const fileName = path.basename(imagePath);
const newPath = path.resolve(path.join(directoryPath, fileName));

Expand All @@ -61,14 +69,12 @@ export namespace MoveStarredImagesRenderer {
} else {
DataStorage.setImageAsNoStar(imagePath);
}

if (index === imagePaths.length - 1) {
done();
}
});
});

if (hasErrors) {
reject("Some errors occurred when moving the files");
} else {
resolve();
}
});
}
}

0 comments on commit dff28d3

Please sign in to comment.