|
|
|
@ -88,6 +88,8 @@
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
let searchWord: string;
|
|
|
|
let searchWord: string;
|
|
|
|
let isSearchingPeople = false;
|
|
|
|
let isSearchingPeople = false;
|
|
|
|
|
|
|
|
let focusedElements: (HTMLButtonElement | null)[] = Array.from({ length: maximumLengthSearchPeople }, () => null);
|
|
|
|
|
|
|
|
let indexFocus: number | null = null;
|
|
|
|
|
|
|
|
|
|
|
|
const searchPeople = async () => {
|
|
|
|
const searchPeople = async () => {
|
|
|
|
if ((people.length < maximumLengthSearchPeople && name.startsWith(searchWord)) || name === '') {
|
|
|
|
if ((people.length < maximumLengthSearchPeople && name.startsWith(searchWord)) || name === '') {
|
|
|
|
@ -116,6 +118,7 @@
|
|
|
|
$: {
|
|
|
|
$: {
|
|
|
|
if (people) {
|
|
|
|
if (people) {
|
|
|
|
suggestedPeople = name ? searchNameLocal(name, people, 5, data.person.id) : [];
|
|
|
|
suggestedPeople = name ? searchNameLocal(name, people, 5, data.person.id) : [];
|
|
|
|
|
|
|
|
indexFocus = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -129,8 +132,51 @@
|
|
|
|
viewMode = ViewMode.MERGE_PEOPLE;
|
|
|
|
viewMode = ViewMode.MERGE_PEOPLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleKeyboardPress = (event: KeyboardEvent) => {
|
|
|
|
|
|
|
|
if (suggestedPeople.length === 0) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$showAssetViewer) {
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
switch (event.key) {
|
|
|
|
|
|
|
|
case 'ArrowDown': {
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
if (indexFocus === null) {
|
|
|
|
|
|
|
|
indexFocus = 0;
|
|
|
|
|
|
|
|
} else if (indexFocus === suggestedPeople.length - 1) {
|
|
|
|
|
|
|
|
indexFocus = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
indexFocus++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
focusedElements[indexFocus]?.focus();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'ArrowUp': {
|
|
|
|
|
|
|
|
if (indexFocus === null) {
|
|
|
|
|
|
|
|
indexFocus = 0;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (indexFocus === 0) {
|
|
|
|
|
|
|
|
indexFocus = suggestedPeople.length - 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
indexFocus--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
focusedElements[indexFocus]?.focus();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'Enter': {
|
|
|
|
|
|
|
|
if (indexFocus !== null) {
|
|
|
|
|
|
|
|
handleSuggestPeople(suggestedPeople[indexFocus]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleEscape = () => {
|
|
|
|
const handleEscape = () => {
|
|
|
|
if ($showAssetViewer) {
|
|
|
|
if ($showAssetViewer || viewMode === ViewMode.SUGGEST_MERGE) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($isMultiSelectState) {
|
|
|
|
if ($isMultiSelectState) {
|
|
|
|
@ -350,6 +396,7 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<svelte:document on:keydown={handleKeyboardPress} />
|
|
|
|
{#if viewMode === ViewMode.UNASSIGN_ASSETS}
|
|
|
|
{#if viewMode === ViewMode.UNASSIGN_ASSETS}
|
|
|
|
<UnMergeFaceSelector
|
|
|
|
<UnMergeFaceSelector
|
|
|
|
assetIds={[...$selectedAssets].map((a) => a.id)}
|
|
|
|
assetIds={[...$selectedAssets].map((a) => a.id)}
|
|
|
|
@ -499,24 +546,24 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{:else}
|
|
|
|
{:else}
|
|
|
|
{#each suggestedPeople as person, index (person.id)}
|
|
|
|
{#each suggestedPeople as person, index (person.id)}
|
|
|
|
<div
|
|
|
|
<button
|
|
|
|
class="flex border-t border-x border-gray-400 dark:border-immich-dark-gray h-14 place-items-center bg-gray-200 p-2 dark:bg-gray-700 hover:bg-gray-300 hover:dark:bg-[#232932] {index ===
|
|
|
|
bind:this={focusedElements[index]}
|
|
|
|
|
|
|
|
class="flex w-full border-t border-gray-400 dark:border-immich-dark-gray h-14 place-items-center bg-gray-200 p-2 dark:bg-gray-700 hover:bg-gray-300 hover:dark:bg-[#232932] focus:bg-gray-300 focus:dark:bg-[#232932] {index ===
|
|
|
|
suggestedPeople.length - 1
|
|
|
|
suggestedPeople.length - 1
|
|
|
|
? 'rounded-b-lg border-b'
|
|
|
|
? 'rounded-b-lg border-b'
|
|
|
|
: ''}"
|
|
|
|
: ''}"
|
|
|
|
|
|
|
|
on:click={() => handleSuggestPeople(person)}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<button class="flex w-full place-items-center" on:click={() => handleSuggestPeople(person)}>
|
|
|
|
<ImageThumbnail
|
|
|
|
<ImageThumbnail
|
|
|
|
circle
|
|
|
|
circle
|
|
|
|
shadow
|
|
|
|
shadow
|
|
|
|
url={api.getPeopleThumbnailUrl(person.id)}
|
|
|
|
url={api.getPeopleThumbnailUrl(person.id)}
|
|
|
|
altText={person.name}
|
|
|
|
altText={person.name}
|
|
|
|
widthStyle="2rem"
|
|
|
|
widthStyle="2rem"
|
|
|
|
heightStyle="2rem"
|
|
|
|
heightStyle="2rem"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<p class="ml-4 text-gray-700 dark:text-gray-100">{person.name}</p>
|
|
|
|
<p class="ml-4 text-gray-700 dark:text-gray-100">{person.name}</p>
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/each}
|
|
|
|
{/each}
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|