mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
fix(web): whitespace in person name (#5401)
* fix(web): whitespace in person name * pr feedback
This commit is contained in:
parent
8b6a79ad9e
commit
b396e0eee3
3 changed files with 36 additions and 17 deletions
32
web/src/lib/utils/person.ts
Normal file
32
web/src/lib/utils/person.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import type { PersonResponseDto } from '@api';
|
||||
|
||||
export const searchNameLocal = (
|
||||
name: string,
|
||||
people: PersonResponseDto[],
|
||||
slice: number,
|
||||
personId?: string,
|
||||
): PersonResponseDto[] => {
|
||||
return name.indexOf(' ') >= 0
|
||||
? people
|
||||
.filter((person: PersonResponseDto) => {
|
||||
if (personId) {
|
||||
return person.name.toLowerCase().startsWith(name.toLowerCase()) && person.id !== personId;
|
||||
} else {
|
||||
return person.name.toLowerCase().startsWith(name.toLowerCase());
|
||||
}
|
||||
})
|
||||
.slice(0, slice)
|
||||
: people
|
||||
.filter((person: PersonResponseDto) => {
|
||||
const nameParts = person.name.split(' ');
|
||||
if (personId) {
|
||||
return (
|
||||
nameParts.some((splitName) => splitName.toLowerCase().startsWith(name.toLowerCase())) &&
|
||||
person.id !== personId
|
||||
);
|
||||
} else {
|
||||
return nameParts.some((splitName) => splitName.toLowerCase().startsWith(name.toLowerCase()));
|
||||
}
|
||||
})
|
||||
.slice(0, slice);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue