mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Fixes error on missing init/mask image
This commit is contained in:
parent
b8e4c13746
commit
2c8806341f
@ -390,14 +390,14 @@ class InvokeAIWebServer:
|
|||||||
|
|
||||||
# TODO: I think this needs a safety mechanism.
|
# TODO: I think this needs a safety mechanism.
|
||||||
@socketio.on('deleteImage')
|
@socketio.on('deleteImage')
|
||||||
def handle_delete_image(path, uuid):
|
def handle_delete_image(url, uuid):
|
||||||
try:
|
try:
|
||||||
print(f'>> Delete requested "{path}"')
|
print(f'>> Delete requested "{url}"')
|
||||||
from send2trash import send2trash
|
from send2trash import send2trash
|
||||||
|
|
||||||
path = self.get_image_path_from_url(path)
|
path = self.get_image_path_from_url(url)
|
||||||
send2trash(path)
|
send2trash(path)
|
||||||
socketio.emit('imageDeleted', {'url': path, 'uuid': uuid})
|
socketio.emit('imageDeleted', {'url': url, 'uuid': uuid})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.socketio.emit('error', {'message': (str(e))})
|
self.socketio.emit('error', {'message': (str(e))})
|
||||||
print('\n')
|
print('\n')
|
||||||
|
483
frontend/dist/assets/index.1dc2a85b.js
vendored
483
frontend/dist/assets/index.1dc2a85b.js
vendored
File diff suppressed because one or more lines are too long
690
frontend/dist/assets/index.73bc96d2.js
vendored
Normal file
690
frontend/dist/assets/index.73bc96d2.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
frontend/dist/index.html
vendored
2
frontend/dist/index.html
vendored
@ -6,7 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>InvokeAI - A Stable Diffusion Toolkit</title>
|
<title>InvokeAI - A Stable Diffusion Toolkit</title>
|
||||||
<link rel="shortcut icon" type="icon" href="/assets/favicon.0d253ced.ico" />
|
<link rel="shortcut icon" type="icon" href="/assets/favicon.0d253ced.ico" />
|
||||||
<script type="module" crossorigin src="/assets/index.1dc2a85b.js"></script>
|
<script type="module" crossorigin src="/assets/index.73bc96d2.js"></script>
|
||||||
<link rel="stylesheet" href="/assets/index.853a336f.css">
|
<link rel="stylesheet" href="/assets/index.853a336f.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -279,6 +279,17 @@ const makeSocketIOListeners = (
|
|||||||
onImageDeleted: (data: InvokeAI.ImageUrlAndUuidResponse) => {
|
onImageDeleted: (data: InvokeAI.ImageUrlAndUuidResponse) => {
|
||||||
const { url, uuid } = data;
|
const { url, uuid } = data;
|
||||||
dispatch(removeImage(uuid));
|
dispatch(removeImage(uuid));
|
||||||
|
|
||||||
|
const { initialImagePath, maskPath } = getState().options;
|
||||||
|
|
||||||
|
if (initialImagePath === url) {
|
||||||
|
dispatch(setInitialImagePath(''));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maskPath === url) {
|
||||||
|
dispatch(setMaskPath(''));
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
addLogEntry({
|
addLogEntry({
|
||||||
timestamp: dateFormat(new Date(), 'isoDateTime'),
|
timestamp: dateFormat(new Date(), 'isoDateTime'),
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Flex, Image } from '@chakra-ui/react';
|
import { Flex, Image } from '@chakra-ui/react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useAppSelector } from '../../app/store';
|
import { useAppDispatch, useAppSelector } from '../../app/store';
|
||||||
import { RootState } from '../../app/store';
|
import { RootState } from '../../app/store';
|
||||||
import { OptionsState } from './optionsSlice';
|
import { OptionsState, setInitialImagePath, setMaskPath } from './optionsSlice';
|
||||||
import './InitAndMaskImage.css';
|
import './InitAndMaskImage.css';
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
@ -23,9 +23,18 @@ const optionsSelector = createSelector(
|
|||||||
* Displays init and mask images and buttons to upload/delete them.
|
* Displays init and mask images and buttons to upload/delete them.
|
||||||
*/
|
*/
|
||||||
const InitAndMaskImage = () => {
|
const InitAndMaskImage = () => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
const { initialImagePath, maskPath } = useAppSelector(optionsSelector);
|
const { initialImagePath, maskPath } = useAppSelector(optionsSelector);
|
||||||
const [shouldShowMask, setShouldShowMask] = useState<boolean>(false);
|
const [shouldShowMask, setShouldShowMask] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const handleInitImageOnError = () => {
|
||||||
|
dispatch(setInitialImagePath(''));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMaskImageOnError = () => {
|
||||||
|
dispatch(setMaskPath(''));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex direction={'column'} alignItems={'center'} gap={2}>
|
<Flex direction={'column'} alignItems={'center'} gap={2}>
|
||||||
<InitAndMaskUploadButtons setShouldShowMask={setShouldShowMask} />
|
<InitAndMaskUploadButtons setShouldShowMask={setShouldShowMask} />
|
||||||
@ -37,6 +46,7 @@ const InitAndMaskImage = () => {
|
|||||||
rounded={'md'}
|
rounded={'md'}
|
||||||
className={'checkerboard'}
|
className={'checkerboard'}
|
||||||
maxWidth={320}
|
maxWidth={320}
|
||||||
|
onError={handleInitImageOnError}
|
||||||
/>
|
/>
|
||||||
{shouldShowMask && maskPath && (
|
{shouldShowMask && maskPath && (
|
||||||
<Image
|
<Image
|
||||||
@ -48,6 +58,7 @@ const InitAndMaskImage = () => {
|
|||||||
src={maskPath}
|
src={maskPath}
|
||||||
rounded={'md'}
|
rounded={'md'}
|
||||||
zIndex={1}
|
zIndex={1}
|
||||||
|
onError={handleMaskImageOnError}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user