Clean duplicate aliases when creating from performer tagger (#4801)

* Clean duplicate aliases when creating from performer tagger
* Use case insensitive name matching
This commit is contained in:
WithoutPants 2024-05-03 13:10:35 +10:00 committed by GitHub
parent 0bba8889b8
commit 22d14fd89e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,6 +18,21 @@ interface IStashSearchResultProps {
excludedPerformerFields: string[];
}
// #4596 - remove any duplicate aliases or aliases that are the same as the performer's name
function cleanAliases(currentName: string, aliases: string[]) {
const ret: string[] = [];
aliases.forEach((alias) => {
if (
alias.toLowerCase() !== currentName.toLowerCase() &&
!ret.find((r) => r.toLowerCase() === alias.toLowerCase())
) {
ret.push(alias);
}
});
return ret;
}
const StashSearchResult: React.FC<IStashSearchResultProps> = ({
performer,
stashboxPerformers,
@ -43,6 +58,10 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
input.stash_ids = mergeStashIDs(performer.stash_ids, input.stash_ids);
}
if (input.alias_list) {
input.alias_list = cleanAliases(performer.name, input.alias_list);
}
const updateData: GQL.PerformerUpdateInput = {
...input,
id: performer.id,