mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-25 06:22:14 -03:00
Add support for importing multiple latest images
Introduces a new backend route and method to fetch all images created since a given timestamp, and updates the frontend to import all new images as layers on auto-refresh. This improves workflow by allowing multiple images generated in a single execution to be imported at once, rather than only the most recent image.
This commit is contained in:
14
js/Canvas.js
14
js/Canvas.js
@@ -459,11 +459,17 @@ export class Canvas {
|
||||
|
||||
_addAutoRefreshToggle() {
|
||||
let autoRefreshEnabled = false;
|
||||
let lastExecutionStartTime = 0;
|
||||
|
||||
const handleExecutionStart = () => {
|
||||
lastExecutionStartTime = Date.now();
|
||||
log.debug(`Execution started, timestamp set to: ${lastExecutionStartTime}`);
|
||||
};
|
||||
|
||||
const handleExecutionSuccess = () => {
|
||||
if (autoRefreshEnabled) {
|
||||
log.info('Auto-refresh triggered, importing latest image.');
|
||||
this.importLatestImage();
|
||||
log.info('Auto-refresh triggered, importing latest images.');
|
||||
this.canvasIO.importLatestImages(lastExecutionStartTime);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -479,10 +485,12 @@ export class Canvas {
|
||||
}
|
||||
);
|
||||
|
||||
api.addEventListener('execution_start', handleExecutionStart);
|
||||
api.addEventListener('execution_success', handleExecutionSuccess);
|
||||
|
||||
this.node.onRemoved = useChainCallback(this.node.onRemoved, () => {
|
||||
log.info('Node removed, cleaning up auto-refresh listener.');
|
||||
log.info('Node removed, cleaning up auto-refresh listeners.');
|
||||
api.removeEventListener('execution_start', handleExecutionStart);
|
||||
api.removeEventListener('execution_success', handleExecutionSuccess);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user