Skip to content

Commit b88f98b

Browse files
authored
feat(web): Add "set as featured" option for an asset (#14879)
1 parent c3be74c commit b88f98b

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,7 @@
11421142
"set": "Set",
11431143
"set_as_album_cover": "Set as album cover",
11441144
"set_as_profile_picture": "Set as profile picture",
1145+
"set_as_featured_photo": "Set as featured photo",
11451146
"set_date_of_birth": "Set date of birth",
11461147
"set_profile_picture": "Set profile picture",
11471148
"set_slideshow_to_fullscreen": "Set Slideshow to fullscreen",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script lang="ts">
2+
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
3+
import {
4+
notificationController,
5+
NotificationType,
6+
} from '$lib/components/shared-components/notification/notification';
7+
import { handleError } from '$lib/utils/handle-error';
8+
import { updatePerson, type AssetResponseDto, type PersonResponseDto } from '@immich/sdk';
9+
import { mdiFaceManProfile } from '@mdi/js';
10+
import { t } from 'svelte-i18n';
11+
12+
interface Props {
13+
asset: AssetResponseDto;
14+
person: PersonResponseDto;
15+
}
16+
17+
let { asset, person }: Props = $props();
18+
19+
const handleSelectFeaturePhoto = async () => {
20+
try {
21+
await updatePerson({ id: person.id, personUpdateDto: { featureFaceAssetId: asset.id } });
22+
notificationController.show({ message: $t('feature_photo_updated'), type: NotificationType.Info });
23+
} catch (error) {
24+
handleError(error, $t('errors.unable_to_set_feature_photo'));
25+
}
26+
};
27+
</script>
28+
29+
<MenuOption text={$t('set_as_featured_photo')} icon={mdiFaceManProfile} onClick={handleSelectFeaturePhoto} />

web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import FavoriteAction from '$lib/components/asset-viewer/actions/favorite-action.svelte';
1010
import RestoreAction from '$lib/components/asset-viewer/actions/restore-action.svelte';
1111
import SetAlbumCoverAction from '$lib/components/asset-viewer/actions/set-album-cover-action.svelte';
12+
import SetFeaturedPhotoAction from '$lib/components/asset-viewer/actions/set-person-featured-action.svelte';
1213
import SetProfilePictureAction from '$lib/components/asset-viewer/actions/set-profile-picture-action.svelte';
1314
import ShareAction from '$lib/components/asset-viewer/actions/share-action.svelte';
1415
import ShowDetailAction from '$lib/components/asset-viewer/actions/show-detail-action.svelte';
@@ -27,6 +28,7 @@
2728
AssetTypeEnum,
2829
type AlbumResponseDto,
2930
type AssetResponseDto,
31+
type PersonResponseDto,
3032
type StackResponseDto,
3133
} from '@immich/sdk';
3234
import {
@@ -50,6 +52,7 @@
5052
interface Props {
5153
asset: AssetResponseDto;
5254
album?: AlbumResponseDto | null;
55+
person?: PersonResponseDto | null;
5356
stack?: StackResponseDto | null;
5457
showDetailButton: boolean;
5558
showSlideshow?: boolean;
@@ -67,6 +70,7 @@
6770
let {
6871
asset,
6972
album = null,
73+
person = null,
7074
stack = null,
7175
showDetailButton,
7276
showSlideshow = false,
@@ -169,6 +173,9 @@
169173
{#if album}
170174
<SetAlbumCoverAction {asset} {album} />
171175
{/if}
176+
{#if person}
177+
<SetFeaturedPhotoAction {asset} {person} />
178+
{/if}
172179
{#if asset.type === AssetTypeEnum.Image}
173180
<SetProfilePictureAction {asset} />
174181
{/if}

web/src/lib/components/asset-viewer/asset-viewer.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
type ActivityResponseDto,
3131
type AlbumResponseDto,
3232
type AssetResponseDto,
33+
type PersonResponseDto,
3334
type StackResponseDto,
3435
} from '@immich/sdk';
3536
import { onDestroy, onMount, untrack } from 'svelte';
@@ -56,6 +57,7 @@
5657
withStacked?: boolean;
5758
isShared?: boolean;
5859
album?: AlbumResponseDto | null;
60+
person?: PersonResponseDto | null;
5961
onAction?: OnAction | undefined;
6062
reactions?: ActivityResponseDto[];
6163
onClose: (dto: { asset: AssetResponseDto }) => void;
@@ -72,6 +74,7 @@
7274
withStacked = false,
7375
isShared = false,
7476
album = null,
77+
person = null,
7578
onAction = undefined,
7679
reactions = $bindable([]),
7780
onClose,
@@ -429,6 +432,7 @@
429432
<AssetViewerNavBar
430433
{asset}
431434
{album}
435+
{person}
432436
{stack}
433437
showDetailButton={enableDetailPanel}
434438
showSlideshow={!!assetStore}

web/src/lib/components/photos-page/asset-grid.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
type ScrollTargetListener,
2020
} from '$lib/utils/timeline-util';
2121
import { TUNABLES } from '$lib/utils/tunables';
22-
import type { AlbumResponseDto, AssetResponseDto } from '@immich/sdk';
22+
import type { AlbumResponseDto, AssetResponseDto, PersonResponseDto } from '@immich/sdk';
2323
import { throttle } from 'lodash-es';
2424
import { onDestroy, onMount, type Snippet } from 'svelte';
2525
import Portal from '../shared-components/portal/portal.svelte';
@@ -52,6 +52,7 @@
5252
showArchiveIcon?: boolean;
5353
isShared?: boolean;
5454
album?: AlbumResponseDto | null;
55+
person?: PersonResponseDto | null;
5556
isShowDeleteConfirmation?: boolean;
5657
onSelect?: (asset: AssetResponseDto) => void;
5758
onEscape?: () => void;
@@ -70,6 +71,7 @@
7071
showArchiveIcon = false,
7172
isShared = false,
7273
album = null,
74+
person = null,
7375
isShowDeleteConfirmation = $bindable(false),
7476
onSelect = () => {},
7577
onEscape = () => {},
@@ -914,6 +916,7 @@
914916
preloadAssets={$preloadAssets}
915917
{isShared}
916918
{album}
919+
{person}
917920
onAction={handleAction}
918921
onPrevious={handlePrevious}
919922
onNext={handleNext}

web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@
454454
{#key person.id}
455455
<AssetGrid
456456
enableRouting={true}
457+
{person}
457458
{assetStore}
458459
{assetInteraction}
459460
isSelectionMode={viewMode === PersonPageViewMode.SELECT_PERSON}

0 commit comments

Comments
 (0)