re-add alt-text
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import type { TimelineAsset } from '$lib/stores/assets-store.svelte';
|
||||
import { AssetTypeEnum, type AssetResponseDto } from '@immich/sdk';
|
||||
import { t } from 'svelte-i18n';
|
||||
import { derived } from 'svelte/store';
|
||||
import { fromLocalDateTime } from './timeline-util';
|
||||
@@ -44,24 +43,18 @@ export const getAltTextForTimelineAsset = (_: TimelineAsset) => {
|
||||
};
|
||||
|
||||
export const getAltText = derived(t, ($t) => {
|
||||
return (asset: AssetResponseDto | null | undefined) => {
|
||||
if (!asset) {
|
||||
return '';
|
||||
}
|
||||
if (asset.exifInfo?.description) {
|
||||
return asset.exifInfo.description;
|
||||
}
|
||||
|
||||
return (asset: TimelineAsset) => {
|
||||
const date = fromLocalDateTime(asset.localDateTime).toLocaleString({ dateStyle: 'long' });
|
||||
const hasPlace = !!asset.exifInfo?.city && !!asset.exifInfo?.country;
|
||||
const names = asset.people?.filter((p) => p.name).map((p) => p.name) ?? [];
|
||||
const { city, country, people: names } = asset.text;
|
||||
const hasPlace = city && country;
|
||||
|
||||
const peopleCount = names.length;
|
||||
const isVideo = asset.type === AssetTypeEnum.Video;
|
||||
const isVideo = asset.isVideo;
|
||||
|
||||
const values = {
|
||||
date,
|
||||
city: asset.exifInfo?.city,
|
||||
country: asset.exifInfo?.country,
|
||||
city,
|
||||
country,
|
||||
person1: names[0],
|
||||
person2: names[1],
|
||||
person3: names[2],
|
||||
|
||||
@@ -114,6 +114,14 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset):
|
||||
const assetResponse = unknownAsset as AssetResponseDto;
|
||||
const { width, height } = getAssetRatio(assetResponse);
|
||||
const ratio = width / height;
|
||||
const city = assetResponse.exifInfo?.city;
|
||||
const country = assetResponse.exifInfo?.country;
|
||||
const people = assetResponse.people?.map((person) => person.name) || [];
|
||||
const text = {
|
||||
city: city || null,
|
||||
country: country || null,
|
||||
people,
|
||||
};
|
||||
return {
|
||||
id: assetResponse.id,
|
||||
ownerId: assetResponse.ownerId,
|
||||
@@ -129,6 +137,7 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset):
|
||||
duration: assetResponse.duration || null,
|
||||
projectionType: assetResponse.exifInfo?.projectionType || null,
|
||||
livePhotoVideoId: assetResponse.livePhotoVideoId || null,
|
||||
text,
|
||||
};
|
||||
};
|
||||
export const isTimelineAsset = (arg: AssetResponseDto | TimelineAsset): arg is TimelineAsset =>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
function getBoolean(string: string | null, fallback: boolean) {
|
||||
if (string === null) {
|
||||
return fallback;
|
||||
@@ -11,13 +12,11 @@ function getNumber(string: string | null, fallback: number) {
|
||||
}
|
||||
return Number.parseInt(string);
|
||||
}
|
||||
|
||||
const storage = browser
|
||||
? localStorage
|
||||
: {
|
||||
getItem: () => null,
|
||||
};
|
||||
|
||||
export const TUNABLES = {
|
||||
LAYOUT: {
|
||||
WASM: getBoolean(storage.getItem('LAYOUT.WASM'), false),
|
||||
|
||||
Reference in New Issue
Block a user