Skip to content

Commit

Permalink
Add function for duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Sep 25, 2023
1 parent c0b98ce commit 4a1eb47
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ui/v2.5/src/components/Tagger/scenes/PerformerResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({

const [selectedPerformer, setSelectedPerformer] = useState<Performer>();

function selectPerformer(selected: Performer | undefined) {
setSelectedPerformer(selected);
setSelectedID(selected?.id);
}

useEffect(() => {
if (
performerData?.findPerformer &&
Expand All @@ -55,17 +60,14 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({

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 <div>Loading performer</div>;
Expand Down

0 comments on commit 4a1eb47

Please sign in to comment.