mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
setting up event listeners for bulk download socket
This commit is contained in:
parent
c7ed5606bd
commit
6828962c05
@ -0,0 +1,9 @@
|
|||||||
|
import { atom } from 'nanostores';
|
||||||
|
|
||||||
|
export const DEFAULT_BULK_DOWNLOAD_ID = 'default';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The download id for a bulk download. Used for socket subscriptions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const $bulkDownloadId = atom<string>(DEFAULT_BULK_DOWNLOAD_ID);
|
@ -18,7 +18,7 @@ export const initialConfigState: AppConfig = {
|
|||||||
shouldUpdateImagesOnConnect: false,
|
shouldUpdateImagesOnConnect: false,
|
||||||
shouldFetchMetadataFromApi: false,
|
shouldFetchMetadataFromApi: false,
|
||||||
disabledTabs: [],
|
disabledTabs: [],
|
||||||
disabledFeatures: ['lightbox', 'faceRestore', 'batches', 'bulkDownload'],
|
disabledFeatures: ['lightbox', 'faceRestore', 'batches'],
|
||||||
disabledSDFeatures: ['variation', 'symmetry', 'hires', 'perlinNoise', 'noiseThreshold'],
|
disabledSDFeatures: ['variation', 'symmetry', 'hires', 'perlinNoise', 'noiseThreshold'],
|
||||||
nodesAllowlist: undefined,
|
nodesAllowlist: undefined,
|
||||||
nodesDenylist: undefined,
|
nodesDenylist: undefined,
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { createAction } from '@reduxjs/toolkit';
|
import { createAction } from '@reduxjs/toolkit';
|
||||||
import type {
|
import type {
|
||||||
|
BulkDownloadCompletedEvent,
|
||||||
|
BulkDownloadFailedEvent,
|
||||||
|
BulkDownloadStartedEvent,
|
||||||
GeneratorProgressEvent,
|
GeneratorProgressEvent,
|
||||||
GraphExecutionStateCompleteEvent,
|
GraphExecutionStateCompleteEvent,
|
||||||
InvocationCompleteEvent,
|
InvocationCompleteEvent,
|
||||||
@ -64,3 +67,15 @@ export const socketInvocationRetrievalError = createAction<{
|
|||||||
export const socketQueueItemStatusChanged = createAction<{
|
export const socketQueueItemStatusChanged = createAction<{
|
||||||
data: QueueItemStatusChangedEvent;
|
data: QueueItemStatusChangedEvent;
|
||||||
}>('socket/socketQueueItemStatusChanged');
|
}>('socket/socketQueueItemStatusChanged');
|
||||||
|
|
||||||
|
export const socketBulkDownloadStarted = createAction<{
|
||||||
|
data: BulkDownloadStartedEvent;
|
||||||
|
}>('socket/socketBulkDownloadStarted');
|
||||||
|
|
||||||
|
export const socketBulkDownloadCompleted = createAction<{
|
||||||
|
data: BulkDownloadCompletedEvent;
|
||||||
|
}>('socket/socketBulkDownloadCompleted');
|
||||||
|
|
||||||
|
export const socketBulkDownloadFailed = createAction<{
|
||||||
|
data: BulkDownloadFailedEvent;
|
||||||
|
}>('socket/socketBulkDownloadFailed');
|
||||||
|
@ -156,7 +156,7 @@ export type InvocationRetrievalErrorEvent = {
|
|||||||
*
|
*
|
||||||
* @example socket.on('queue_item_status_changed', (data: QueueItemStatusChangedEvent) => { ... }
|
* @example socket.on('queue_item_status_changed', (data: QueueItemStatusChangedEvent) => { ... }
|
||||||
*/
|
*/
|
||||||
export type QueueItemStatusChangedEvent = {
|
export type QueueItemStatusChangedEvent = {
|
||||||
queue_id: string;
|
queue_id: string;
|
||||||
queue_item: {
|
queue_item: {
|
||||||
queue_id: string;
|
queue_id: string;
|
||||||
@ -191,7 +191,7 @@ export type QueueItemStatusChangedEvent = {
|
|||||||
failed: number;
|
failed: number;
|
||||||
canceled: number;
|
canceled: number;
|
||||||
total: number;
|
total: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ClientEmitSubscribeQueue = {
|
export type ClientEmitSubscribeQueue = {
|
||||||
@ -202,6 +202,31 @@ export type ClientEmitUnsubscribeQueue = {
|
|||||||
queue_id: string;
|
queue_id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type BulkDownloadStartedEvent = {
|
||||||
|
bulk_download_id: string;
|
||||||
|
bulk_download_item_id: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BulkDownloadCompletedEvent = {
|
||||||
|
bulk_download_id: string;
|
||||||
|
bulk_download_item_id: string;
|
||||||
|
bulk_download_item_name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BulkDownloadFailedEvent = {
|
||||||
|
bulk_download_id: string;
|
||||||
|
bulk_download_item_id: string;
|
||||||
|
error: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ClientEmitSubscribeBulkDownload = {
|
||||||
|
bulk_download_id: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ClientEmitUnsubscribeBulkDownload = {
|
||||||
|
bulk_download_id: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type ServerToClientEvents = {
|
export type ServerToClientEvents = {
|
||||||
generator_progress: (payload: GeneratorProgressEvent) => void;
|
generator_progress: (payload: GeneratorProgressEvent) => void;
|
||||||
invocation_complete: (payload: InvocationCompleteEvent) => void;
|
invocation_complete: (payload: InvocationCompleteEvent) => void;
|
||||||
@ -213,6 +238,9 @@ export type ServerToClientEvents = {
|
|||||||
session_retrieval_error: (payload: SessionRetrievalErrorEvent) => void;
|
session_retrieval_error: (payload: SessionRetrievalErrorEvent) => void;
|
||||||
invocation_retrieval_error: (payload: InvocationRetrievalErrorEvent) => void;
|
invocation_retrieval_error: (payload: InvocationRetrievalErrorEvent) => void;
|
||||||
queue_item_status_changed: (payload: QueueItemStatusChangedEvent) => void;
|
queue_item_status_changed: (payload: QueueItemStatusChangedEvent) => void;
|
||||||
|
bulk_download_started: (payload: BulkDownloadStartedEvent) => void;
|
||||||
|
bulk_download_completed: (payload: BulkDownloadCompletedEvent) => void;
|
||||||
|
bulk_download_failed: (payload: BulkDownloadFailedEvent) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ClientToServerEvents = {
|
export type ClientToServerEvents = {
|
||||||
@ -220,4 +248,6 @@ export type ClientToServerEvents = {
|
|||||||
disconnect: () => void;
|
disconnect: () => void;
|
||||||
subscribe_queue: (payload: ClientEmitSubscribeQueue) => void;
|
subscribe_queue: (payload: ClientEmitSubscribeQueue) => void;
|
||||||
unsubscribe_queue: (payload: ClientEmitUnsubscribeQueue) => void;
|
unsubscribe_queue: (payload: ClientEmitUnsubscribeQueue) => void;
|
||||||
|
subscribe_bulk_download: (payload: ClientEmitSubscribeBulkDownload) => void;
|
||||||
|
unsubscribe_bulk_download: (payload: ClientEmitUnsubscribeBulkDownload) => void;
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
|
import { $bulkDownloadId } from 'app/store/nanostores/bulkDownloadId';
|
||||||
import { $queueId } from 'app/store/nanostores/queueId';
|
import { $queueId } from 'app/store/nanostores/queueId';
|
||||||
import type { AppDispatch } from 'app/store/store';
|
import type { AppDispatch } from 'app/store/store';
|
||||||
import { addToast } from 'features/system/store/systemSlice';
|
import { addToast } from 'features/system/store/systemSlice';
|
||||||
import { makeToast } from 'features/system/util/makeToast';
|
import { makeToast } from 'features/system/util/makeToast';
|
||||||
import {
|
import {
|
||||||
|
socketBulkDownloadCompleted,
|
||||||
|
socketBulkDownloadFailed,
|
||||||
|
socketBulkDownloadStarted,
|
||||||
socketConnected,
|
socketConnected,
|
||||||
socketDisconnected,
|
socketDisconnected,
|
||||||
socketGeneratorProgress,
|
socketGeneratorProgress,
|
||||||
@ -34,6 +38,8 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
|||||||
dispatch(socketConnected());
|
dispatch(socketConnected());
|
||||||
const queue_id = $queueId.get();
|
const queue_id = $queueId.get();
|
||||||
socket.emit('subscribe_queue', { queue_id });
|
socket.emit('subscribe_queue', { queue_id });
|
||||||
|
const bulk_download_id = $bulkDownloadId.get();
|
||||||
|
socket.emit('subscribe_bulk_download', { bulk_download_id });
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('connect_error', (error) => {
|
socket.on('connect_error', (error) => {
|
||||||
@ -150,4 +156,16 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
|||||||
socket.on('queue_item_status_changed', (data) => {
|
socket.on('queue_item_status_changed', (data) => {
|
||||||
dispatch(socketQueueItemStatusChanged({ data }));
|
dispatch(socketQueueItemStatusChanged({ data }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('bulk_download_started', (data) => {
|
||||||
|
dispatch(socketBulkDownloadStarted({ data }));
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('bulk_download_completed', (data) => {
|
||||||
|
dispatch(socketBulkDownloadCompleted({ data }));
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('bulk_download_failed', (data) => {
|
||||||
|
dispatch(socketBulkDownloadFailed({ data }));
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user