From 4a1eb474a8511fe9daf668027061fd9945a74f7b Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 25 Sep 2023 10:44:20 +1000 Subject: [PATCH] Add function for duplicated code --- .../components/Tagger/scenes/PerformerResult.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/v2.5/src/components/Tagger/scenes/PerformerResult.tsx b/ui/v2.5/src/components/Tagger/scenes/PerformerResult.tsx index 35d609e7b59..6afbc442730 100755 --- a/ui/v2.5/src/components/Tagger/scenes/PerformerResult.tsx +++ b/ui/v2.5/src/components/Tagger/scenes/PerformerResult.tsx @@ -44,6 +44,11 @@ const PerformerResult: React.FC = ({ const [selectedPerformer, setSelectedPerformer] = useState(); + function selectPerformer(selected: Performer | undefined) { + setSelectedPerformer(selected); + setSelectedID(selected?.id); + } + useEffect(() => { if ( performerData?.findPerformer && @@ -55,17 +60,14 @@ const PerformerResult: React.FC = ({ const handleSelect = (performers: Performer[]) => { if (performers.length) { - setSelectedPerformer(performers[0]); - setSelectedID(performers[0].id); + selectPerformer(performers[0]); } else { - setSelectedPerformer(undefined); - setSelectedID(undefined); + selectPerformer(undefined); } }; const handleSkip = () => { - setSelectedPerformer(undefined); - setSelectedID(undefined); + selectPerformer(undefined); }; if (stashLoading) return
Loading performer
;