浏览代码

fix(web) show exif info in public shared (#1283)

* fix(web) show exif in public share page

* Added exif info to return payload'
Alex 2 年之前
父节点
当前提交
7add754fc3

+ 1 - 1
server/apps/immich/src/api-v1/share/share.core.ts

@@ -48,7 +48,7 @@ export class ShareCore {
 
 
   async getSharedLinkById(id: string): Promise<SharedLinkEntity> {
   async getSharedLinkById(id: string): Promise<SharedLinkEntity> {
     const link = await this.sharedLinkRepository.getById(id);
     const link = await this.sharedLinkRepository.getById(id);
-
+    console.log(link);
     if (!link) {
     if (!link) {
       throw new BadRequestException('Shared link not found');
       throw new BadRequestException('Shared link not found');
     }
     }

+ 6 - 2
server/apps/immich/src/api-v1/share/shared-link.repository.ts

@@ -57,10 +57,14 @@ export class SharedLinkRepository implements ISharedLinkRepository {
         id: id,
         id: id,
       },
       },
       relations: {
       relations: {
-        assets: true,
+        assets: {
+          exifInfo: true,
+        },
         album: {
         album: {
           assets: {
           assets: {
-            assetInfo: true,
+            assetInfo: {
+              exifInfo: true,
+            },
           },
           },
         },
         },
       },
       },

+ 8 - 9
web/src/lib/components/asset-viewer/asset-viewer.svelte

@@ -23,14 +23,6 @@
 	export let publicSharedKey = '';
 	export let publicSharedKey = '';
 	export let showNavigation = true;
 	export let showNavigation = true;
 
 
-	$: {
-		appearsInAlbums = [];
-
-		api.albumApi.getAllAlbums(undefined, asset.id).then((result) => {
-			appearsInAlbums = result.data;
-		});
-	}
-
 	const dispatch = createEventDispatcher();
 	const dispatch = createEventDispatcher();
 	let halfLeftHover = false;
 	let halfLeftHover = false;
 	let halfRightHover = false;
 	let halfRightHover = false;
@@ -41,8 +33,15 @@
 	let shouldPlayMotionPhoto = false;
 	let shouldPlayMotionPhoto = false;
 	const onKeyboardPress = (keyInfo: KeyboardEvent) => handleKeyboardPress(keyInfo.key);
 	const onKeyboardPress = (keyInfo: KeyboardEvent) => handleKeyboardPress(keyInfo.key);
 
 
-	onMount(() => {
+	onMount(async () => {
 		document.addEventListener('keydown', onKeyboardPress);
 		document.addEventListener('keydown', onKeyboardPress);
+
+		try {
+			const { data } = await api.albumApi.getAllAlbums(undefined, asset.id);
+			appearsInAlbums = data;
+		} catch (e) {
+			console.error('Error getting album that asset belong to', e);
+		}
 	});
 	});
 
 
 	onDestroy(() => {
 	onDestroy(() => {

+ 1 - 1
web/src/lib/components/asset-viewer/detail-panel.svelte

@@ -23,7 +23,7 @@
 		drawMap(asset.exifInfo.latitude, asset.exifInfo.longitude);
 		drawMap(asset.exifInfo.latitude, asset.exifInfo.longitude);
 	}
 	}
 
 
-	export let albums: AlbumResponseDto[];
+	export let albums: AlbumResponseDto[] = [];
 
 
 	onMount(async () => {
 	onMount(async () => {
 		if (browser) {
 		if (browser) {