Skip to content

Commit

Permalink
Removing queued images when removing folder
Browse files Browse the repository at this point in the history
  • Loading branch information
wladimiiir committed Oct 30, 2024
1 parent d339ac7 commit cf836b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/ipcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ export const setupIpcHandlers = (webContents: Electron.WebContents, store: Store

ipcMain.handle('remove-images-in-folder', async (_event, folderPath: string) => {
const images = store.getImages();
const imagesToRemove = images.filter((image) => image.id.startsWith(folderPath));
const updatedImages = images.filter((image) => !image.id.startsWith(folderPath));
store.setImages(updatedImages);
modelManager.removeQueuedImages(imagesToRemove);
return updatedImages;
});
};
5 changes: 5 additions & 0 deletions src/main/modelManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,9 @@ export class ModelManager {

return modelProvider.generateImageInfo(settings, image);
}

removeQueuedImages(imagesToRemove: Image[]): void {
const imageIds = new Set(imagesToRemove.map((img) => img.id));
this.queue = this.queue.filter((item) => !imageIds.has(item.image.id));
}
}

0 comments on commit cf836b2

Please sign in to comment.