Compare commits

...

2 Commits

6 changed files with 13 additions and 7 deletions

View File

@ -2,6 +2,7 @@ import React, { PropsWithChildren } from 'react';
import { IAIPopoverProps } from '../web/src/common/components/IAIPopover'; import { IAIPopoverProps } from '../web/src/common/components/IAIPopover';
import { IAIIconButtonProps } from '../web/src/common/components/IAIIconButton'; import { IAIIconButtonProps } from '../web/src/common/components/IAIIconButton';
import { InvokeTabName } from 'features/ui/store/tabMap'; import { InvokeTabName } from 'features/ui/store/tabMap';
import { PartialAppConfig } from 'app/invokeai';
export {}; export {};
@ -77,11 +78,8 @@ declare module '@invoke-ai/invoke-ai-ui' {
interface InvokeProps extends PropsWithChildren { interface InvokeProps extends PropsWithChildren {
apiUrl?: string; apiUrl?: string;
disabledPanels?: string[];
disabledTabs?: InvokeTabName[];
token?: string; token?: string;
shouldTransformUrls?: boolean; config?: PartialAppConfig;
shouldFetchImages?: boolean;
} }
declare function Invoke(props: InvokeProps): JSX.Element; declare function Invoke(props: InvokeProps): JSX.Element;

View File

@ -30,7 +30,6 @@ interface Props extends PropsWithChildren {
} }
const App = ({ config = {}, children }: Props) => { const App = ({ config = {}, children }: Props) => {
useToastWatcher();
useGlobalHotkeys(); useGlobalHotkeys();
const currentTheme = useAppSelector((state) => state.ui.currentTheme); const currentTheme = useAppSelector((state) => state.ui.currentTheme);
@ -57,6 +56,8 @@ const App = ({ config = {}, children }: Props) => {
setLoadingOverridden(true); setLoadingOverridden(true);
}, []); }, []);
useToastWatcher(config);
return ( return (
<Grid w="100vw" h="100vh" position="relative"> <Grid w="100vw" h="100vh" position="relative">
{isLightboxEnabled && <Lightbox />} {isLightboxEnabled && <Lightbox />}

View File

@ -376,6 +376,7 @@ export declare type AppConfig = {
disabledTabs: InvokeTabName[]; disabledTabs: InvokeTabName[];
disabledFeatures: AppFeature[]; disabledFeatures: AppFeature[];
canRestoreDeletedImagesFromBin: boolean; canRestoreDeletedImagesFromBin: boolean;
displayToasts: boolean;
sd: { sd: {
iterations: { iterations: {
initial: number; initial: number;

View File

@ -3,6 +3,7 @@ import { useAppDispatch, useAppSelector } from 'app/storeHooks';
import { toastQueueSelector } from 'features/system/store/systemSelectors'; import { toastQueueSelector } from 'features/system/store/systemSelectors';
import { clearToastQueue } from 'features/system/store/systemSlice'; import { clearToastQueue } from 'features/system/store/systemSlice';
import { useEffect } from 'react'; import { useEffect } from 'react';
import { PartialAppConfig } from 'app/invokeai';
export type MakeToastArg = string | UseToastOptions; export type MakeToastArg = string | UseToastOptions;
@ -19,16 +20,19 @@ export const makeToast = (arg: MakeToastArg): UseToastOptions => {
return { status: 'info', isClosable: true, duration: 2500, ...arg }; return { status: 'info', isClosable: true, duration: 2500, ...arg };
}; };
const useToastWatcher = () => { const useToastWatcher = (config: PartialAppConfig) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const toastQueue = useAppSelector(toastQueueSelector); const toastQueue = useAppSelector(toastQueueSelector);
const toast = useToast(); const toast = useToast();
useEffect(() => { useEffect(() => {
if (!config!.displayToasts) return;
toastQueue.forEach((t) => { toastQueue.forEach((t) => {
toast(t); toast(t);
}); });
toastQueue.length > 0 && dispatch(clearToastQueue()); toastQueue.length > 0 && dispatch(clearToastQueue());
}, [dispatch, toast, toastQueue]); }, [dispatch, toast, toastQueue, config]);
}; };
export default useToastWatcher; export default useToastWatcher;

View File

@ -9,6 +9,7 @@ const initialConfigState: AppConfig = {
disabledTabs: [], disabledTabs: [],
disabledFeatures: [], disabledFeatures: [],
canRestoreDeletedImagesFromBin: true, canRestoreDeletedImagesFromBin: true,
displayToasts: true,
sd: { sd: {
iterations: { iterations: {
initial: 1, initial: 1,

View File

@ -498,6 +498,7 @@ export const systemSlice = createSlice({
state.wasErrorSeen = true; state.wasErrorSeen = true;
state.progressImage = null; state.progressImage = null;
state.isProcessing = false; state.isProcessing = false;
state.currentStatus = i18n.t('common.statusError');
state.toastQueue.push( state.toastQueue.push(
makeToast({ title: i18n.t('toast.serverError'), status: 'error' }) makeToast({ title: i18n.t('toast.serverError'), status: 'error' })