|
16 | 16 | import { locale } from '$lib/stores/preferences.store'; |
17 | 17 | import { featureFlags } from '$lib/stores/server-config.store'; |
18 | 18 | import { preferences, user } from '$lib/stores/user.store'; |
19 | | - import { getAssetThumbnailUrl, getPeopleThumbnailUrl, handlePromiseError } from '$lib/utils'; |
20 | | - import { delay, isFlipped } from '$lib/utils/asset-utils'; |
| 19 | + import { getAssetThumbnailUrl, getPeopleThumbnailUrl } from '$lib/utils'; |
| 20 | + import { delay, getDimensions } from '$lib/utils/asset-utils'; |
21 | 21 | import { getByteUnitString } from '$lib/utils/byte-units'; |
22 | 22 | import { handleError } from '$lib/utils/handle-error'; |
23 | 23 | import { getMetadataSearchQuery } from '$lib/utils/metadata-search'; |
24 | 24 | import { fromISODateTime, fromISODateTimeUTC } from '$lib/utils/timeline-util'; |
25 | 25 | import { getParentPath } from '$lib/utils/tree-utils'; |
26 | | - import { |
27 | | - AssetMediaSize, |
28 | | - getAssetInfo, |
29 | | - updateAsset, |
30 | | - type AlbumResponseDto, |
31 | | - type AssetResponseDto, |
32 | | - type ExifResponseDto, |
33 | | - } from '@immich/sdk'; |
| 26 | + import { AssetMediaSize, getAssetInfo, updateAsset, type AlbumResponseDto, type AssetResponseDto } from '@immich/sdk'; |
34 | 27 | import { IconButton } from '@immich/ui'; |
35 | 28 | import { |
36 | 29 | mdiCalendar, |
|
61 | 54 |
|
62 | 55 | let { asset, albums = [], currentAlbum = null, onClose }: Props = $props(); |
63 | 56 |
|
64 | | - const getDimensions = (exifInfo: ExifResponseDto) => { |
65 | | - const { exifImageWidth: width, exifImageHeight: height } = exifInfo; |
66 | | - if (isFlipped(exifInfo.orientation)) { |
67 | | - return { width: height, height: width }; |
68 | | - } |
69 | | -
|
70 | | - return { width, height }; |
71 | | - }; |
72 | | -
|
73 | 57 | let showAssetPath = $state(false); |
74 | 58 | let showEditFaces = $state(false); |
75 | | - let previousId: string | undefined = $state(); |
76 | | -
|
77 | | - $effect(() => { |
78 | | - if (!previousId) { |
79 | | - previousId = asset.id; |
80 | | - } |
81 | | - if (asset.id !== previousId) { |
82 | | - showEditFaces = false; |
83 | | - previousId = asset.id; |
84 | | - } |
85 | | - }); |
86 | | -
|
87 | 59 | let isOwner = $derived($user?.id === asset.ownerId); |
88 | | -
|
89 | | - const handleNewAsset = async (newAsset: AssetResponseDto) => { |
90 | | - // TODO: check if reloading asset data is necessary |
91 | | - if (newAsset.id && !authManager.isSharedLink) { |
92 | | - const data = await getAssetInfo({ id: asset.id }); |
93 | | - people = data?.people || []; |
94 | | - unassignedFaces = data?.unassignedFaces || []; |
95 | | - } |
96 | | - }; |
97 | | -
|
98 | | - $effect(() => { |
99 | | - handlePromiseError(handleNewAsset(asset)); |
100 | | - }); |
101 | | -
|
| 60 | + let people = $derived(asset.people || []); |
| 61 | + let unassignedFaces = $derived(asset.unassignedFaces || []); |
| 62 | + let showingHiddenPeople = $state(false); |
| 63 | + let timeZone = $derived(asset.exifInfo?.timeZone); |
| 64 | + let dateTime = $derived( |
| 65 | + timeZone && asset.exifInfo?.dateTimeOriginal |
| 66 | + ? fromISODateTime(asset.exifInfo.dateTimeOriginal, timeZone) |
| 67 | + : fromISODateTimeUTC(asset.localDateTime), |
| 68 | + ); |
102 | 69 | let latlng = $derived( |
103 | 70 | (() => { |
104 | 71 | const lat = asset.exifInfo?.latitude; |
|
109 | 76 | } |
110 | 77 | })(), |
111 | 78 | ); |
| 79 | + let previousId: string | undefined = $state(); |
112 | 80 |
|
113 | | - let people = $state(asset.people || []); |
114 | | - let unassignedFaces = $state(asset.unassignedFaces || []); |
115 | | - let showingHiddenPeople = $state(false); |
116 | | - let timeZone = $derived(asset.exifInfo?.timeZone); |
117 | | - let dateTime = $derived( |
118 | | - timeZone && asset.exifInfo?.dateTimeOriginal |
119 | | - ? fromISODateTime(asset.exifInfo.dateTimeOriginal, timeZone) |
120 | | - : fromISODateTimeUTC(asset.localDateTime), |
121 | | - ); |
| 81 | + $effect(() => { |
| 82 | + if (!previousId) { |
| 83 | + previousId = asset.id; |
| 84 | + } |
| 85 | + if (asset.id !== previousId) { |
| 86 | + showEditFaces = false; |
| 87 | + previousId = asset.id; |
| 88 | + } |
| 89 | + }); |
122 | 90 |
|
123 | 91 | const getMegapixel = (width: number, height: number): number | undefined => { |
124 | 92 | const megapixel = Math.round((height * width) / 1_000_000); |
|
131 | 99 | }; |
132 | 100 |
|
133 | 101 | const handleRefreshPeople = async () => { |
134 | | - await getAssetInfo({ id: asset.id }).then((data) => { |
135 | | - people = data?.people || []; |
136 | | - unassignedFaces = data?.unassignedFaces || []; |
137 | | - }); |
| 102 | + asset = await getAssetInfo({ id: asset.id }); |
138 | 103 | showEditFaces = false; |
139 | 104 | }; |
140 | 105 |
|
|
0 commit comments