mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Fixes rerenders on ClearBrushHistory
This commit is contained in:
parent
db46e12f2b
commit
6e33ca7e9e
@ -1,6 +1,5 @@
|
|||||||
import { useToast } from '@chakra-ui/react';
|
import { useToast } from '@chakra-ui/react';
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import React from 'react';
|
|
||||||
import {
|
import {
|
||||||
RootState,
|
RootState,
|
||||||
useAppDispatch,
|
useAppDispatch,
|
||||||
@ -18,8 +17,7 @@ const clearBrushHistorySelector = createSelector(
|
|||||||
(inpainting: InpaintingState) => {
|
(inpainting: InpaintingState) => {
|
||||||
const { pastLines, futureLines } = inpainting;
|
const { pastLines, futureLines } = inpainting;
|
||||||
return {
|
return {
|
||||||
pastLines,
|
mayClearBrushHistory: futureLines.length > 0 || pastLines.length > 0 ? false : true
|
||||||
futureLines,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -33,7 +31,7 @@ export default function ClearBrushHistory() {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
const { pastLines, futureLines } = useAppSelector(clearBrushHistorySelector);
|
const { mayClearBrushHistory } = useAppSelector(clearBrushHistorySelector);
|
||||||
|
|
||||||
const handleClearBrushHistory = () => {
|
const handleClearBrushHistory = () => {
|
||||||
dispatch(setClearBrushHistory());
|
dispatch(setClearBrushHistory());
|
||||||
@ -49,7 +47,7 @@ export default function ClearBrushHistory() {
|
|||||||
label="Clear Brush History"
|
label="Clear Brush History"
|
||||||
onClick={handleClearBrushHistory}
|
onClick={handleClearBrushHistory}
|
||||||
tooltip="Clears brush stroke history"
|
tooltip="Clears brush stroke history"
|
||||||
disabled={futureLines.length > 0 || pastLines.length > 0 ? false : true}
|
disabled={mayClearBrushHistory}
|
||||||
styleClass="inpainting-options-btn"
|
styleClass="inpainting-options-btn"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user