From 9eb091f8733ce422432dca97cbde7f7afd52a89a Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:49:22 +1000 Subject: [PATCH] feat(ui): add redux events for queue cleared & batch enqueued socket events --- invokeai/frontend/web/src/services/events/actions.ts | 4 ++++ .../frontend/web/src/services/events/setEventListeners.ts | 8 ++++++++ invokeai/frontend/web/src/services/events/types.ts | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/invokeai/frontend/web/src/services/events/actions.ts b/invokeai/frontend/web/src/services/events/actions.ts index a97bdcbf8b..b36fadcf79 100644 --- a/invokeai/frontend/web/src/services/events/actions.ts +++ b/invokeai/frontend/web/src/services/events/actions.ts @@ -1,5 +1,6 @@ import { createAction } from '@reduxjs/toolkit'; import type { + BatchEnqueuedEvent, BulkDownloadCompleteEvent, BulkDownloadFailedEvent, BulkDownloadStartedEvent, @@ -21,6 +22,7 @@ import type { ModelInstallStartedEvent, ModelLoadCompleteEvent, ModelLoadStartedEvent, + QueueClearedEvent, QueueItemStatusChangedEvent, } from 'services/events/types'; @@ -57,6 +59,8 @@ export const socketModelInstallError = createSocketAction('ModelInstallCancelledEvent'); export const socketQueueItemStatusChanged = createSocketAction('QueueItemStatusChangedEvent'); +export const socketQueueCleared = createSocketAction('QueueClearedEvent'); +export const socketBatchEnqueued = createSocketAction('BatchEnqueuedEvent'); export const socketBulkDownloadStarted = createSocketAction('BulkDownloadStartedEvent'); export const socketBulkDownloadComplete = createSocketAction('BulkDownloadCompleteEvent'); export const socketBulkDownloadError = createSocketAction('BulkDownloadFailedEvent'); diff --git a/invokeai/frontend/web/src/services/events/setEventListeners.ts b/invokeai/frontend/web/src/services/events/setEventListeners.ts index 6bc0154ef0..8c8c9da2e8 100644 --- a/invokeai/frontend/web/src/services/events/setEventListeners.ts +++ b/invokeai/frontend/web/src/services/events/setEventListeners.ts @@ -4,6 +4,7 @@ import { $queueId } from 'app/store/nanostores/queueId'; import type { AppDispatch } from 'app/store/store'; import { toast } from 'features/toast/toast'; import { + socketBatchEnqueued, socketBulkDownloadComplete, socketBulkDownloadError, socketBulkDownloadStarted, @@ -26,6 +27,7 @@ import { socketModelInstallStarted, socketModelLoadComplete, socketModelLoadStarted, + socketQueueCleared, socketQueueItemStatusChanged, } from 'services/events/actions'; import type { ClientToServerEvents, ServerToClientEvents } from 'services/events/types'; @@ -116,6 +118,12 @@ export const setEventListeners = ({ socket, dispatch }: SetEventListenersArg) => socket.on('queue_item_status_changed', (data) => { dispatch(socketQueueItemStatusChanged({ data })); }); + socket.on('queue_cleared', (data) => { + dispatch(socketQueueCleared({ data })); + }); + socket.on('batch_enqueued', (data) => { + dispatch(socketBatchEnqueued({ data })); + }); socket.on('bulk_download_started', (data) => { dispatch(socketBulkDownloadStarted({ data })); }); diff --git a/invokeai/frontend/web/src/services/events/types.ts b/invokeai/frontend/web/src/services/events/types.ts index 2d3725394d..ad6d08379a 100644 --- a/invokeai/frontend/web/src/services/events/types.ts +++ b/invokeai/frontend/web/src/services/events/types.ts @@ -24,6 +24,8 @@ export type DownloadCancelledEvent = S['DownloadCancelledEvent']; export type DownloadErrorEvent = S['DownloadErrorEvent']; export type QueueItemStatusChangedEvent = S['QueueItemStatusChangedEvent']; +export type QueueClearedEvent = S['QueueClearedEvent']; +export type BatchEnqueuedEvent = S['BatchEnqueuedEvent']; export type BulkDownloadStartedEvent = S['BulkDownloadStartedEvent']; export type BulkDownloadCompleteEvent = S['BulkDownloadCompleteEvent']; @@ -58,6 +60,8 @@ export type ServerToClientEvents = { model_install_cancelled: (payload: ModelInstallCancelledEvent) => void; model_load_complete: (payload: ModelLoadCompleteEvent) => void; queue_item_status_changed: (payload: QueueItemStatusChangedEvent) => void; + queue_cleared: (payload: QueueClearedEvent) => void; + batch_enqueued: (payload: BatchEnqueuedEvent) => void; bulk_download_started: (payload: BulkDownloadStartedEvent) => void; bulk_download_complete: (payload: BulkDownloadCompleteEvent) => void; bulk_download_error: (payload: BulkDownloadFailedEvent) => void;