From 5630e541e3f3ea8d46470d5bc40be07a7a68c814 Mon Sep 17 00:00:00 2001 From: Mees Frensel <33722705+meesfrensel@users.noreply.github.com> Date: Tue, 27 Oct 2026 15:56:04 +0100 Subject: [PATCH] refactor(web): clean up (#32627) (cherry picked from commit 5ff8436781681755042fe6416024d0c4885b851d) --- i18n/en.json | 2 +- .../asset-viewer/ActivityViewer.svelte | 13 +++++-------- web/src/lib/utils/asset-utils.ts | 19 ++----------------- web/src/lib/utils/context-menu.ts | 2 +- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index b70f998e9..8e5840a55 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -2338,7 +2338,7 @@ "user": "User", "user_has_been_deleted": "This user has been deleted.", "user_id": "User ID", - "user_liked": "{user} liked {type, select, photo {this photo} video {this video} asset {this asset} other {it}}", + "user_liked": "{user} liked {type, select, image {this photo} video {this video} other {this}}", "user_pin_code_settings": "PIN Code", "user_pin_code_settings_description": "Manage your PIN code", "user_privacy": "User Privacy", diff --git a/web/src/lib/components/asset-viewer/ActivityViewer.svelte b/web/src/lib/components/asset-viewer/ActivityViewer.svelte index a9db0160f..e56e5ad83 100644 --- a/web/src/lib/components/asset-viewer/ActivityViewer.svelte +++ b/web/src/lib/components/asset-viewer/ActivityViewer.svelte @@ -7,10 +7,9 @@ import { Route } from '#lib/route.ts'; import { locale } from '#lib/stores/preferences.store.ts'; import { getAssetMediaUrl } from '#lib/utils.ts'; - import { getAssetType } from '#lib/utils/asset-utils.ts'; import { handleError } from '#lib/utils/handle-error.ts'; import { isTenMinutesApart } from '#lib/utils/timesince.ts'; - import { ReactionType, type ActivityResponseDto, type AlbumUserResponseDto, type AssetTypeEnum } from '@immich/sdk'; + import { AssetTypeEnum, ReactionType, type ActivityResponseDto, type AlbumUserResponseDto } from '@immich/sdk'; import { ContextMenuButton, Icon, IconButton, LoadingSpinner, Textarea, toastManager } from '@immich/ui'; import { mdiClose, mdiSend, mdiThumbUp, mdiTrashCanOutline } from '@mdi/js'; import * as luxon from 'luxon'; @@ -188,17 +187,15 @@ {/if} {:else if reaction.type === ReactionType.Like} + {const type = $derived( + assetType === AssetTypeEnum.Image || assetType === AssetTypeEnum.Video ? assetType.toLowerCase() : null, + )}
- {$t('user_liked', { - values: { - user: reaction.user.name, - type: assetType ? getAssetType(assetType).toLowerCase() : null, - }, - })} + {$t('user_liked', { values: { user: reaction.user.name, type } })}
{#if assetId === undefined && reaction.assetId} diff --git a/web/src/lib/utils/asset-utils.ts b/web/src/lib/utils/asset-utils.ts index 93c21488e..f39bd251b 100644 --- a/web/src/lib/utils/asset-utils.ts +++ b/web/src/lib/utils/asset-utils.ts @@ -19,7 +19,6 @@ import { updateAsset, updateAssets, type AssetResponseDto, - type AssetTypeEnum, type DownloadInfoDto, type ExifResponseDto, type UserResponseDto, @@ -126,7 +125,7 @@ function isRotated270CW(orientation: number) { return [7, 8, -90].includes(orientation); } -export function isFlipped(orientation?: string | null) { +function isFlipped(orientation?: string | null) { const value = Number(orientation); return value && (isRotated270CW(value) || isRotated90CW(value)); } @@ -150,7 +149,7 @@ export function getAssetResolution(asset: AssetResponseDto): string { return 'Invalid Data'; } - return `${asset.width} x ${asset.height}`; + return `${asset.width} × ${asset.height}`; } /** @@ -234,20 +233,6 @@ export function isWebCompatibleImage(asset: AssetResponseDto): boolean { return supportedImageMimeTypes.has(asset.originalMimeType); } -export const getAssetType = (type: AssetTypeEnum) => { - switch (type) { - case 'IMAGE': { - return 'Photo'; - } - case 'VIDEO': { - return 'Video'; - } - default: { - return 'Asset'; - } - } -}; - export const getOwnedAssetsWithWarning = (assets: TimelineAsset[], user: UserResponseDto | null): string[] => { const ids = [...assets].filter((a) => user && a.ownerId === user.id).map((a) => a.id); diff --git a/web/src/lib/utils/context-menu.ts b/web/src/lib/utils/context-menu.ts index 461856145..3602c7b51 100644 --- a/web/src/lib/utils/context-menu.ts +++ b/web/src/lib/utils/context-menu.ts @@ -1,6 +1,6 @@ export type Align = 'middle' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; -export type ContextMenuPosition = { x: number; y: number }; +type ContextMenuPosition = { x: number; y: number }; export const getContextMenuPositionFromEvent = ( event: MouseEvent | KeyboardEvent,