From 6e33ca7e9e64fb355430511e28bb08c32c9c68b1 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 2 Nov 2022 10:59:01 +1100 Subject: [PATCH] Fixes rerenders on ClearBrushHistory --- .../AdvancedOptions/Inpainting/ClearBrushHistory.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/src/features/options/AdvancedOptions/Inpainting/ClearBrushHistory.tsx b/frontend/src/features/options/AdvancedOptions/Inpainting/ClearBrushHistory.tsx index 9d5b1acc14..98735b2c0b 100644 --- a/frontend/src/features/options/AdvancedOptions/Inpainting/ClearBrushHistory.tsx +++ b/frontend/src/features/options/AdvancedOptions/Inpainting/ClearBrushHistory.tsx @@ -1,6 +1,5 @@ import { useToast } from '@chakra-ui/react'; import { createSelector } from '@reduxjs/toolkit'; -import React from 'react'; import { RootState, useAppDispatch, @@ -18,8 +17,7 @@ const clearBrushHistorySelector = createSelector( (inpainting: InpaintingState) => { const { pastLines, futureLines } = inpainting; return { - pastLines, - futureLines, + mayClearBrushHistory: futureLines.length > 0 || pastLines.length > 0 ? false : true }; }, { @@ -33,7 +31,7 @@ export default function ClearBrushHistory() { const dispatch = useAppDispatch(); const toast = useToast(); - const { pastLines, futureLines } = useAppSelector(clearBrushHistorySelector); + const { mayClearBrushHistory } = useAppSelector(clearBrushHistorySelector); const handleClearBrushHistory = () => { dispatch(setClearBrushHistory()); @@ -49,7 +47,7 @@ export default function ClearBrushHistory() { label="Clear Brush History" onClick={handleClearBrushHistory} tooltip="Clears brush stroke history" - disabled={futureLines.length > 0 || pastLines.length > 0 ? false : true} + disabled={mayClearBrushHistory} styleClass="inpainting-options-btn" /> );