Skip to content

Commit

Permalink
Misc. tweaks
Browse files Browse the repository at this point in the history
* `refreshImages` no longer needs an `emitChanges` arg
* prefer `array.some` to `array.find` to determine existence only

Signed-off-by: Eric Promislow <epromislow@suse.com>
  • Loading branch information
ericpromislow committed May 10, 2021
1 parent 0fe09d3 commit a6f770c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Electron.ipcMain.on('confirm-do-image-deletion', async(event, imageName, imageID
for (i = 0; i < maxNumAttempts; i++) {
await imageManager.deleteImage(imageID);
await imageManager.refreshImages();
if (!imageManager.listImages().find(image => image.imageID === imageID)) {
if (!imageManager.listImages().some(image => image.imageID === imageID)) {
break;
}
await util.promisify(setTimeout)(500);
Expand Down
6 changes: 2 additions & 4 deletions src/k8s-engine/kim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class Kim extends EventEmitter {
return this.images;
}

async refreshImages(emitChanges = true) {
async refreshImages() {
try {
const result: childResultType = await this.getImages();

Expand All @@ -149,9 +149,7 @@ export default class Kim extends EventEmitter {
this.images = this.parse(result.stdout);
// Start a new interval for image-list refreshing
this.start();
if (emitChanges) {
this.emit('images-changed', this.images);
}
this.emit('images-changed', this.images);
} catch (err) {
if (!this.showedStderr) {
if (err.stderr && !err.stdout && !err.signal) {
Expand Down

0 comments on commit a6f770c

Please sign in to comment.