import { useToast } from '@chakra-ui/react'; import { createSelector } from '@reduxjs/toolkit'; import React, { ChangeEvent } from 'react'; import { RootState, useAppDispatch, useAppSelector, } from '../../../../app/store'; import IAIButton from '../../../../common/components/IAIButton'; import { InpaintingState, setClearBrushHistory, setInpaintReplace, setShouldUseInpaintReplace, } from '../../../tabs/Inpainting/inpaintingSlice'; import BoundingBoxSettings from './BoundingBoxSettings'; import _ from 'lodash'; import IAINumberInput from '../../../../common/components/IAINumberInput'; import IAISwitch from '../../../../common/components/IAISwitch'; const inpaintingSelector = createSelector( (state: RootState) => state.inpainting, (inpainting: InpaintingState) => { const { pastLines, futureLines, inpaintReplace, shouldUseInpaintReplace } = inpainting; return { pastLines, futureLines, inpaintReplace, shouldUseInpaintReplace, }; }, { memoizeOptions: { resultEqualityCheck: _.isEqual, }, } ); export default function InpaintingSettings() { const dispatch = useAppDispatch(); const toast = useToast(); const { pastLines, futureLines, inpaintReplace, shouldUseInpaintReplace } = useAppSelector(inpaintingSelector); const handleClearBrushHistory = () => { dispatch(setClearBrushHistory()); toast({ title: 'Brush Stroke History Cleared', status: 'success', duration: 2500, isClosable: true, }); }; return ( <> 0 || pastLines.length > 0 ? false : true} /> { dispatch(setInpaintReplace(v)); }} /> ) => dispatch(setShouldUseInpaintReplace(e.target.checked)) } /> > ); }