mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05:00 
			
		
		
		
	fix(web): only show the timezone when it is known (#12779)
This commit is contained in:
		
							parent
							
								
									96516ae4b9
								
							
						
					
					
						commit
						0b02fda4e0
					
				@ -1,5 +1,9 @@
 | 
				
			|||||||
<script lang="ts">
 | 
					<script lang="ts">
 | 
				
			||||||
 | 
					  import { goto } from '$app/navigation';
 | 
				
			||||||
 | 
					  import DetailPanelDescription from '$lib/components/asset-viewer/detail-panel-description.svelte';
 | 
				
			||||||
  import DetailPanelLocation from '$lib/components/asset-viewer/detail-panel-location.svelte';
 | 
					  import DetailPanelLocation from '$lib/components/asset-viewer/detail-panel-location.svelte';
 | 
				
			||||||
 | 
					  import DetailPanelRating from '$lib/components/asset-viewer/detail-panel-star-rating.svelte';
 | 
				
			||||||
 | 
					  import DetailPanelTags from '$lib/components/asset-viewer/detail-panel-tags.svelte';
 | 
				
			||||||
  import Icon from '$lib/components/elements/icon.svelte';
 | 
					  import Icon from '$lib/components/elements/icon.svelte';
 | 
				
			||||||
  import ChangeDate from '$lib/components/shared-components/change-date.svelte';
 | 
					  import ChangeDate from '$lib/components/shared-components/change-date.svelte';
 | 
				
			||||||
  import { AppRoute, QueryParameter, timeToLoadTheMap } from '$lib/constants';
 | 
					  import { AppRoute, QueryParameter, timeToLoadTheMap } from '$lib/constants';
 | 
				
			||||||
@ -9,6 +13,9 @@
 | 
				
			|||||||
  import { preferences, user } from '$lib/stores/user.store';
 | 
					  import { preferences, user } from '$lib/stores/user.store';
 | 
				
			||||||
  import { getAssetThumbnailUrl, getPeopleThumbnailUrl, handlePromiseError, isSharedLink } from '$lib/utils';
 | 
					  import { getAssetThumbnailUrl, getPeopleThumbnailUrl, handlePromiseError, isSharedLink } from '$lib/utils';
 | 
				
			||||||
  import { delay, isFlipped } from '$lib/utils/asset-utils';
 | 
					  import { delay, isFlipped } from '$lib/utils/asset-utils';
 | 
				
			||||||
 | 
					  import { getByteUnitString } from '$lib/utils/byte-units';
 | 
				
			||||||
 | 
					  import { handleError } from '$lib/utils/handle-error';
 | 
				
			||||||
 | 
					  import { fromDateTimeOriginal, fromLocalDateTime } from '$lib/utils/timeline-util';
 | 
				
			||||||
  import {
 | 
					  import {
 | 
				
			||||||
    AssetMediaSize,
 | 
					    AssetMediaSize,
 | 
				
			||||||
    getAssetInfo,
 | 
					    getAssetInfo,
 | 
				
			||||||
@ -18,6 +25,7 @@
 | 
				
			|||||||
    type ExifResponseDto,
 | 
					    type ExifResponseDto,
 | 
				
			||||||
  } from '@immich/sdk';
 | 
					  } from '@immich/sdk';
 | 
				
			||||||
  import {
 | 
					  import {
 | 
				
			||||||
 | 
					    mdiAccountOff,
 | 
				
			||||||
    mdiCalendar,
 | 
					    mdiCalendar,
 | 
				
			||||||
    mdiCameraIris,
 | 
					    mdiCameraIris,
 | 
				
			||||||
    mdiClose,
 | 
					    mdiClose,
 | 
				
			||||||
@ -26,24 +34,17 @@
 | 
				
			|||||||
    mdiImageOutline,
 | 
					    mdiImageOutline,
 | 
				
			||||||
    mdiInformationOutline,
 | 
					    mdiInformationOutline,
 | 
				
			||||||
    mdiPencil,
 | 
					    mdiPencil,
 | 
				
			||||||
    mdiAccountOff,
 | 
					 | 
				
			||||||
  } from '@mdi/js';
 | 
					  } from '@mdi/js';
 | 
				
			||||||
  import { DateTime } from 'luxon';
 | 
					  import { DateTime } from 'luxon';
 | 
				
			||||||
  import { createEventDispatcher } from 'svelte';
 | 
					  import { createEventDispatcher } from 'svelte';
 | 
				
			||||||
 | 
					  import { t } from 'svelte-i18n';
 | 
				
			||||||
  import { slide } from 'svelte/transition';
 | 
					  import { slide } from 'svelte/transition';
 | 
				
			||||||
  import { getByteUnitString } from '$lib/utils/byte-units';
 | 
					 | 
				
			||||||
  import { handleError } from '$lib/utils/handle-error';
 | 
					 | 
				
			||||||
  import ImageThumbnail from '../assets/thumbnail/image-thumbnail.svelte';
 | 
					  import ImageThumbnail from '../assets/thumbnail/image-thumbnail.svelte';
 | 
				
			||||||
  import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
 | 
					  import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
 | 
				
			||||||
  import PersonSidePanel from '../faces-page/person-side-panel.svelte';
 | 
					  import PersonSidePanel from '../faces-page/person-side-panel.svelte';
 | 
				
			||||||
  import UserAvatar from '../shared-components/user-avatar.svelte';
 | 
					 | 
				
			||||||
  import LoadingSpinner from '../shared-components/loading-spinner.svelte';
 | 
					  import LoadingSpinner from '../shared-components/loading-spinner.svelte';
 | 
				
			||||||
 | 
					  import UserAvatar from '../shared-components/user-avatar.svelte';
 | 
				
			||||||
  import AlbumListItemDetails from './album-list-item-details.svelte';
 | 
					  import AlbumListItemDetails from './album-list-item-details.svelte';
 | 
				
			||||||
  import DetailPanelDescription from '$lib/components/asset-viewer/detail-panel-description.svelte';
 | 
					 | 
				
			||||||
  import DetailPanelRating from '$lib/components/asset-viewer/detail-panel-star-rating.svelte';
 | 
					 | 
				
			||||||
  import { t } from 'svelte-i18n';
 | 
					 | 
				
			||||||
  import { goto } from '$app/navigation';
 | 
					 | 
				
			||||||
  import DetailPanelTags from '$lib/components/asset-viewer/detail-panel-tags.svelte';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  export let asset: AssetResponseDto;
 | 
					  export let asset: AssetResponseDto;
 | 
				
			||||||
  export let albums: AlbumResponseDto[] = [];
 | 
					  export let albums: AlbumResponseDto[] = [];
 | 
				
			||||||
@ -99,6 +100,12 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  $: unassignedFaces = asset.unassignedFaces || [];
 | 
					  $: unassignedFaces = asset.unassignedFaces || [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  $: timeZone = asset.exifInfo?.timeZone;
 | 
				
			||||||
 | 
					  $: dateTime =
 | 
				
			||||||
 | 
					    timeZone && asset.exifInfo?.dateTimeOriginal
 | 
				
			||||||
 | 
					      ? fromDateTimeOriginal(asset.exifInfo.dateTimeOriginal, timeZone)
 | 
				
			||||||
 | 
					      : fromLocalDateTime(asset.localDateTime);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const dispatch = createEventDispatcher<{
 | 
					  const dispatch = createEventDispatcher<{
 | 
				
			||||||
    close: void;
 | 
					    close: void;
 | 
				
			||||||
  }>();
 | 
					  }>();
 | 
				
			||||||
@ -261,10 +268,7 @@
 | 
				
			|||||||
      <p class="text-sm">{$t('no_exif_info_available').toUpperCase()}</p>
 | 
					      <p class="text-sm">{$t('no_exif_info_available').toUpperCase()}</p>
 | 
				
			||||||
    {/if}
 | 
					    {/if}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    {#if asset.exifInfo?.dateTimeOriginal}
 | 
					    {#if dateTime}
 | 
				
			||||||
      {@const assetDateTimeOriginal = DateTime.fromISO(asset.exifInfo.dateTimeOriginal, {
 | 
					 | 
				
			||||||
        zone: asset.exifInfo.timeZone ?? undefined,
 | 
					 | 
				
			||||||
      })}
 | 
					 | 
				
			||||||
      <button
 | 
					      <button
 | 
				
			||||||
        type="button"
 | 
					        type="button"
 | 
				
			||||||
        class="flex w-full text-left justify-between place-items-start gap-4 py-4"
 | 
					        class="flex w-full text-left justify-between place-items-start gap-4 py-4"
 | 
				
			||||||
@ -280,7 +284,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          <div>
 | 
					          <div>
 | 
				
			||||||
            <p>
 | 
					            <p>
 | 
				
			||||||
              {assetDateTimeOriginal.toLocaleString(
 | 
					              {dateTime.toLocaleString(
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                  month: 'short',
 | 
					                  month: 'short',
 | 
				
			||||||
                  day: 'numeric',
 | 
					                  day: 'numeric',
 | 
				
			||||||
@ -291,12 +295,12 @@
 | 
				
			|||||||
            </p>
 | 
					            </p>
 | 
				
			||||||
            <div class="flex gap-2 text-sm">
 | 
					            <div class="flex gap-2 text-sm">
 | 
				
			||||||
              <p>
 | 
					              <p>
 | 
				
			||||||
                {assetDateTimeOriginal.toLocaleString(
 | 
					                {dateTime.toLocaleString(
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    weekday: 'short',
 | 
					                    weekday: 'short',
 | 
				
			||||||
                    hour: 'numeric',
 | 
					                    hour: 'numeric',
 | 
				
			||||||
                    minute: '2-digit',
 | 
					                    minute: '2-digit',
 | 
				
			||||||
                    timeZoneName: 'longOffset',
 | 
					                    timeZoneName: timeZone ? 'longOffset' : undefined,
 | 
				
			||||||
                  },
 | 
					                  },
 | 
				
			||||||
                  { locale: $locale },
 | 
					                  { locale: $locale },
 | 
				
			||||||
                )}
 | 
					                )}
 | 
				
			||||||
@ -325,16 +329,9 @@
 | 
				
			|||||||
    {/if}
 | 
					    {/if}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    {#if isShowChangeDate}
 | 
					    {#if isShowChangeDate}
 | 
				
			||||||
      {@const assetDateTimeOriginal = asset.exifInfo?.dateTimeOriginal
 | 
					 | 
				
			||||||
        ? DateTime.fromISO(asset.exifInfo.dateTimeOriginal, {
 | 
					 | 
				
			||||||
            zone: asset.exifInfo.timeZone ?? undefined,
 | 
					 | 
				
			||||||
            locale: $locale,
 | 
					 | 
				
			||||||
          })
 | 
					 | 
				
			||||||
        : DateTime.now()}
 | 
					 | 
				
			||||||
      {@const assetTimeZoneOriginal = asset.exifInfo?.timeZone ?? ''}
 | 
					 | 
				
			||||||
      <ChangeDate
 | 
					      <ChangeDate
 | 
				
			||||||
        initialDate={assetDateTimeOriginal}
 | 
					        initialDate={dateTime}
 | 
				
			||||||
        initialTimeZone={assetTimeZoneOriginal}
 | 
					        initialTimeZone={timeZone ?? ''}
 | 
				
			||||||
        on:confirm={({ detail: date }) => handleConfirmChangeDate(date)}
 | 
					        on:confirm={({ detail: date }) => handleConfirmChangeDate(date)}
 | 
				
			||||||
        on:cancel={() => (isShowChangeDate = false)}
 | 
					        on:cancel={() => (isShowChangeDate = false)}
 | 
				
			||||||
      />
 | 
					      />
 | 
				
			||||||
 | 
				
			|||||||
@ -36,6 +36,9 @@ export type ScrollTargetListener = ({
 | 
				
			|||||||
export const fromLocalDateTime = (localDateTime: string) =>
 | 
					export const fromLocalDateTime = (localDateTime: string) =>
 | 
				
			||||||
  DateTime.fromISO(localDateTime, { zone: 'UTC', locale: get(locale) });
 | 
					  DateTime.fromISO(localDateTime, { zone: 'UTC', locale: get(locale) });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const fromDateTimeOriginal = (dateTimeOriginal: string, timeZone: string) =>
 | 
				
			||||||
 | 
					  DateTime.fromISO(dateTimeOriginal, { zone: timeZone });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const groupDateFormat: Intl.DateTimeFormatOptions = {
 | 
					export const groupDateFormat: Intl.DateTimeFormatOptions = {
 | 
				
			||||||
  weekday: 'short',
 | 
					  weekday: 'short',
 | 
				
			||||||
  month: 'short',
 | 
					  month: 'short',
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user