mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
fix: Refresh photo after updating featured photo (#21971)
fix: Refresh person photo after setting featured photo Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
a8f683ed15
commit
26e0cb3eb4
5 changed files with 27 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import type { AssetAction } from '$lib/constants';
|
import type { AssetAction } from '$lib/constants';
|
||||||
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
||||||
import type { AlbumResponseDto, AssetResponseDto, StackResponseDto } from '@immich/sdk';
|
import type { AlbumResponseDto, AssetResponseDto, PersonResponseDto, StackResponseDto } from '@immich/sdk';
|
||||||
|
|
||||||
type ActionMap = {
|
type ActionMap = {
|
||||||
[AssetAction.ARCHIVE]: { asset: TimelineAsset };
|
[AssetAction.ARCHIVE]: { asset: TimelineAsset };
|
||||||
|
|
@ -18,6 +18,7 @@ type ActionMap = {
|
||||||
[AssetAction.REMOVE_ASSET_FROM_STACK]: { stack: StackResponseDto | null; asset: AssetResponseDto };
|
[AssetAction.REMOVE_ASSET_FROM_STACK]: { stack: StackResponseDto | null; asset: AssetResponseDto };
|
||||||
[AssetAction.SET_VISIBILITY_LOCKED]: { asset: TimelineAsset };
|
[AssetAction.SET_VISIBILITY_LOCKED]: { asset: TimelineAsset };
|
||||||
[AssetAction.SET_VISIBILITY_TIMELINE]: { asset: TimelineAsset };
|
[AssetAction.SET_VISIBILITY_TIMELINE]: { asset: TimelineAsset };
|
||||||
|
[AssetAction.SET_PERSON_FEATURED_PHOTO]: { asset: AssetResponseDto; person: PersonResponseDto };
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Action = {
|
export type Action = {
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,36 @@
|
||||||
notificationController,
|
notificationController,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
|
import { AssetAction } from '$lib/constants';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
import { updatePerson, type AssetResponseDto, type PersonResponseDto } from '@immich/sdk';
|
import { updatePerson, type AssetResponseDto, type PersonResponseDto } from '@immich/sdk';
|
||||||
import { mdiFaceManProfile } from '@mdi/js';
|
import { mdiFaceManProfile } from '@mdi/js';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
import type { OnAction } from './action';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
asset: AssetResponseDto;
|
asset: AssetResponseDto;
|
||||||
person: PersonResponseDto;
|
person: PersonResponseDto;
|
||||||
|
onAction?: OnAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { asset, person }: Props = $props();
|
let { asset, person, onAction }: Props = $props();
|
||||||
|
|
||||||
const handleSelectFeaturePhoto = async () => {
|
const handleSelectFeaturePhoto = async () => {
|
||||||
try {
|
try {
|
||||||
await updatePerson({ id: person.id, personUpdateDto: { featureFaceAssetId: asset.id } });
|
const updatedPerson = await updatePerson({
|
||||||
|
id: person.id,
|
||||||
|
personUpdateDto: { featureFaceAssetId: asset.id },
|
||||||
|
});
|
||||||
|
|
||||||
|
person = { ...person, ...updatedPerson };
|
||||||
|
|
||||||
|
onAction?.({
|
||||||
|
type: AssetAction.SET_PERSON_FEATURED_PHOTO,
|
||||||
|
asset,
|
||||||
|
person,
|
||||||
|
});
|
||||||
|
|
||||||
notificationController.show({ message: $t('feature_photo_updated'), type: NotificationType.Info });
|
notificationController.show({ message: $t('feature_photo_updated'), type: NotificationType.Info });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, $t('errors.unable_to_set_feature_photo'));
|
handleError(error, $t('errors.unable_to_set_feature_photo'));
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@
|
||||||
<SetAlbumCoverAction {asset} {album} />
|
<SetAlbumCoverAction {asset} {album} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if person}
|
{#if person}
|
||||||
<SetFeaturedPhotoAction {asset} {person} />
|
<SetFeaturedPhotoAction {asset} {person} {onAction} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if asset.type === AssetTypeEnum.Image && !isLocked}
|
{#if asset.type === AssetTypeEnum.Image && !isLocked}
|
||||||
<SetProfilePictureAction {asset} />
|
<SetProfilePictureAction {asset} />
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
import {
|
import {
|
||||||
AssetJobName,
|
AssetJobName,
|
||||||
AssetTypeEnum,
|
AssetTypeEnum,
|
||||||
|
getAssetInfo,
|
||||||
getAllAlbums,
|
getAllAlbums,
|
||||||
getStack,
|
getStack,
|
||||||
runAssetJobs,
|
runAssetJobs,
|
||||||
|
|
@ -339,6 +340,11 @@
|
||||||
stack = action.stack;
|
stack = action.stack;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AssetAction.SET_PERSON_FEATURED_PHOTO: {
|
||||||
|
const assetInfo = await getAssetInfo({ id: asset.id });
|
||||||
|
asset = { ...asset, people: assetInfo.people };
|
||||||
|
break;
|
||||||
|
}
|
||||||
case AssetAction.KEEP_THIS_DELETE_OTHERS:
|
case AssetAction.KEEP_THIS_DELETE_OTHERS:
|
||||||
case AssetAction.UNSTACK: {
|
case AssetAction.UNSTACK: {
|
||||||
closeViewer();
|
closeViewer();
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export enum AssetAction {
|
||||||
REMOVE_ASSET_FROM_STACK = 'remove-asset-from-stack',
|
REMOVE_ASSET_FROM_STACK = 'remove-asset-from-stack',
|
||||||
SET_VISIBILITY_LOCKED = 'set-visibility-locked',
|
SET_VISIBILITY_LOCKED = 'set-visibility-locked',
|
||||||
SET_VISIBILITY_TIMELINE = 'set-visibility-timeline',
|
SET_VISIBILITY_TIMELINE = 'set-visibility-timeline',
|
||||||
|
SET_PERSON_FEATURED_PHOTO = 'set-person-featured-photo',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AppRoute {
|
export enum AppRoute {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue