-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web): don't refresh panorama viewer when modifying asset
- Loading branch information
1 parent
d1169e3
commit 8f3dd10
Showing
6 changed files
with
66 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
web/src/lib/components/asset-viewer/image-panorama-viewer.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script lang="ts"> | ||
import { getAssetOriginalUrl, getKey } from '$lib/utils'; | ||
import { isWebCompatibleImage } from '$lib/utils/asset-utils'; | ||
import { AssetMediaSize, viewAsset, type AssetResponseDto } from '@immich/sdk'; | ||
import { fade } from 'svelte/transition'; | ||
import LoadingSpinner from '../shared-components/loading-spinner.svelte'; | ||
import { t } from 'svelte-i18n'; | ||
interface Props { | ||
asset: AssetResponseDto; | ||
} | ||
const { asset }: Props = $props(); | ||
const loadAssetData = async (id: string) => { | ||
const data = await viewAsset({ id, size: AssetMediaSize.Preview, key: getKey() }); | ||
return URL.createObjectURL(data); | ||
}; | ||
</script> | ||
|
||
<div transition:fade={{ duration: 150 }} class="flex h-full select-none place-content-center place-items-center"> | ||
{#await Promise.all([loadAssetData(asset.id), import('./photo-sphere-viewer-adapter.svelte')])} | ||
<LoadingSpinner /> | ||
{:then [data, { default: PhotoSphereViewer }]} | ||
<PhotoSphereViewer | ||
panorama={data} | ||
originalImageUrl={isWebCompatibleImage(asset) ? getAssetOriginalUrl(asset.id) : undefined} | ||
/> | ||
{:catch} | ||
{$t('errors.failed_to_load_asset')} | ||
{/await} | ||
</div> |
54 changes: 0 additions & 54 deletions
54
web/src/lib/components/asset-viewer/panorama-viewer.svelte
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
web/src/lib/components/asset-viewer/video-panorama-viewer.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script lang="ts"> | ||
import { getAssetOriginalUrl } from '$lib/utils'; | ||
import { fade } from 'svelte/transition'; | ||
import LoadingSpinner from '../shared-components/loading-spinner.svelte'; | ||
import { t } from 'svelte-i18n'; | ||
interface Props { | ||
assetId: string; | ||
} | ||
const { assetId }: Props = $props(); | ||
const modules = Promise.all([ | ||
import('./photo-sphere-viewer-adapter.svelte').then((module) => module.default), | ||
import('@photo-sphere-viewer/equirectangular-video-adapter').then((module) => module.EquirectangularVideoAdapter), | ||
import('@photo-sphere-viewer/video-plugin').then((module) => module.VideoPlugin), | ||
import('@photo-sphere-viewer/video-plugin/index.css'), | ||
]); | ||
</script> | ||
|
||
<div transition:fade={{ duration: 150 }} class="flex h-full select-none place-content-center place-items-center"> | ||
{#await modules} | ||
<LoadingSpinner /> | ||
{:then [PhotoSphereViewer, adapter, videoPlugin]} | ||
<PhotoSphereViewer panorama={{ source: getAssetOriginalUrl(assetId) }} plugins={[videoPlugin]} {adapter} navbar /> | ||
{:catch} | ||
{$t('errors.failed_to_load_asset')} | ||
{/await} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters