Add addLayers method to BatchPreviewManager

Introduces an addLayers method to BatchPreviewManager for adding new layers to an active batch preview or showing the UI if inactive. Updates Canvas to use addLayers instead of show, and fixes a bug where new layers were only added if more than one was present.
This commit is contained in:
Dariusz L
2025-07-03 02:44:07 +02:00
parent c9c0babf3c
commit c4af745b2a
2 changed files with 18 additions and 2 deletions

View File

@@ -134,6 +134,22 @@ export class BatchPreviewManager {
this.canvas.render();
}
addLayers(newLayers) {
if (!newLayers || newLayers.length === 0) {
return;
}
if (this.active) {
// UI is already open, just add the new layers
log.info(`Adding ${newLayers.length} new layers to active batch preview.`);
this.layers.push(...newLayers);
this._update();
} else {
// UI is not open, show it with the new layers
this.show(newLayers);
}
}
navigate(direction) {
this.currentIndex += direction;
if (this.currentIndex < 0) {

View File

@@ -493,8 +493,8 @@ export class Canvas {
log.info('Auto-refresh triggered, importing latest images.');
const newLayers = await this.canvasIO.importLatestImages(lastExecutionStartTime);
if (newLayers && newLayers.length > 1) {
this.batchPreviewManager.show(newLayers);
if (newLayers && newLayers.length > 0) {
this.batchPreviewManager.addLayers(newLayers);
}
}
};