mirror of
https://github.com/immich-app/immich.git
synced 2025-11-01 02:57:08 -04:00
fix: incomplete dynamic imports (#23217)
This commit is contained in:
parent
3f03a88767
commit
6bb1a9e083
@ -440,15 +440,15 @@
|
|||||||
|
|
||||||
{#if latlng && $featureFlags.loaded && $featureFlags.map}
|
{#if latlng && $featureFlags.loaded && $featureFlags.map}
|
||||||
<div class="h-[360px]">
|
<div class="h-[360px]">
|
||||||
{#await import('../shared-components/map/map.svelte')}
|
{#await import('$lib/components/shared-components/map/map.svelte')}
|
||||||
{#await delay(timeToLoadTheMap) then}
|
{#await delay(timeToLoadTheMap) then}
|
||||||
<!-- show the loading spinner only if loading the map takes too much time -->
|
<!-- show the loading spinner only if loading the map takes too much time -->
|
||||||
<div class="flex items-center justify-center h-full w-full">
|
<div class="flex items-center justify-center h-full w-full">
|
||||||
<LoadingSpinner />
|
<LoadingSpinner />
|
||||||
</div>
|
</div>
|
||||||
{/await}
|
{/await}
|
||||||
{:then component}
|
{:then { default: Map }}
|
||||||
<component.default
|
<Map
|
||||||
mapMarkers={[
|
mapMarkers={[
|
||||||
{
|
{
|
||||||
lat: latlng.lat,
|
lat: latlng.lat,
|
||||||
@ -480,7 +480,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</component.default>
|
</Map>
|
||||||
{/await}
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@ -19,7 +19,6 @@
|
|||||||
import { IconButton } from '@immich/ui';
|
import { IconButton } from '@immich/ui';
|
||||||
import { mdiArrowLeft, mdiDownload, mdiFileImagePlusOutline, mdiSelectAll } from '@mdi/js';
|
import { mdiArrowLeft, mdiDownload, mdiFileImagePlusOutline, mdiSelectAll } from '@mdi/js';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import AssetViewer from '../asset-viewer/asset-viewer.svelte';
|
|
||||||
import ControlAppBar from '../shared-components/control-app-bar.svelte';
|
import ControlAppBar from '../shared-components/control-app-bar.svelte';
|
||||||
import GalleryViewer from '../shared-components/gallery-viewer/gallery-viewer.svelte';
|
import GalleryViewer from '../shared-components/gallery-viewer/gallery-viewer.svelte';
|
||||||
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
||||||
@ -146,15 +145,17 @@
|
|||||||
</section>
|
</section>
|
||||||
{:else if assets.length === 1}
|
{:else if assets.length === 1}
|
||||||
{#await getAssetInfo({ ...authManager.params, id: assets[0].id }) then asset}
|
{#await getAssetInfo({ ...authManager.params, id: assets[0].id }) then asset}
|
||||||
<AssetViewer
|
{#await import('$lib/components/asset-viewer/asset-viewer.svelte') then { default: AssetViewer }}
|
||||||
{asset}
|
<AssetViewer
|
||||||
showCloseButton={false}
|
{asset}
|
||||||
onAction={handleAction}
|
showCloseButton={false}
|
||||||
onPrevious={() => Promise.resolve(false)}
|
onAction={handleAction}
|
||||||
onNext={() => Promise.resolve(false)}
|
onPrevious={() => Promise.resolve(false)}
|
||||||
onRandom={() => Promise.resolve(undefined)}
|
onNext={() => Promise.resolve(false)}
|
||||||
onClose={() => {}}
|
onRandom={() => Promise.resolve(undefined)}
|
||||||
/>
|
onClose={() => {}}
|
||||||
|
/>
|
||||||
|
{/await}
|
||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -173,7 +173,7 @@
|
|||||||
|
|
||||||
<span>{$t('pick_a_location')}</span>
|
<span>{$t('pick_a_location')}</span>
|
||||||
<div class="h-[500px] min-h-[300px] w-full z-0">
|
<div class="h-[500px] min-h-[300px] w-full z-0">
|
||||||
{#await import('../shared-components/map/map.svelte')}
|
{#await import('$lib/components/shared-components/map/map.svelte')}
|
||||||
{#await delay(timeToLoadTheMap) then}
|
{#await delay(timeToLoadTheMap) then}
|
||||||
<!-- show the loading spinner only if loading the map takes too much time -->
|
<!-- show the loading spinner only if loading the map takes too much time -->
|
||||||
<div class="flex items-center justify-center h-full w-full">
|
<div class="flex items-center justify-center h-full w-full">
|
||||||
|
|||||||
@ -23,7 +23,6 @@
|
|||||||
import { modalManager } from '@immich/ui';
|
import { modalManager } from '@immich/ui';
|
||||||
import { debounce } from 'lodash-es';
|
import { debounce } from 'lodash-es';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import AssetViewer from '../../asset-viewer/asset-viewer.svelte';
|
|
||||||
import DeleteAssetDialog from '../../photos-page/delete-asset-dialog.svelte';
|
import DeleteAssetDialog from '../../photos-page/delete-asset-dialog.svelte';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -487,16 +486,18 @@
|
|||||||
<!-- Overlay Asset Viewer -->
|
<!-- Overlay Asset Viewer -->
|
||||||
{#if $isViewerOpen}
|
{#if $isViewerOpen}
|
||||||
<Portal target="body">
|
<Portal target="body">
|
||||||
<AssetViewer
|
{#await import('$lib/components/asset-viewer/asset-viewer.svelte') then { default: AssetViewer }}
|
||||||
asset={$viewingAsset}
|
<AssetViewer
|
||||||
onAction={handleAction}
|
asset={$viewingAsset}
|
||||||
onPrevious={handlePrevious}
|
onAction={handleAction}
|
||||||
onNext={handleNext}
|
onPrevious={handlePrevious}
|
||||||
onRandom={handleRandom}
|
onNext={handleNext}
|
||||||
onClose={() => {
|
onRandom={handleRandom}
|
||||||
assetViewingStore.showAssetViewer(false);
|
onClose={() => {
|
||||||
handlePromiseError(navigate({ targetRoute: 'current', assetId: null }));
|
assetViewingStore.showAssetViewer(false);
|
||||||
}}
|
handlePromiseError(navigate({ targetRoute: 'current', assetId: null }));
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
{/await}
|
||||||
</Portal>
|
</Portal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
<script lang="ts" module>
|
<script lang="ts" module>
|
||||||
|
import mapboxRtlUrl from '@mapbox/mapbox-gl-rtl-text/mapbox-gl-rtl-text.min.js?url';
|
||||||
|
import { addProtocol, setRTLTextPlugin } from 'maplibre-gl';
|
||||||
import { Protocol } from 'pmtiles';
|
import { Protocol } from 'pmtiles';
|
||||||
|
|
||||||
let protocol = new Protocol();
|
let protocol = new Protocol();
|
||||||
void maplibregl.addProtocol('pmtiles', protocol.tile);
|
void addProtocol('pmtiles', protocol.tile);
|
||||||
void maplibregl.setRTLTextPlugin(mapboxRtlUrl, true);
|
void setRTLTextPlugin(mapboxRtlUrl, true);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@ -16,12 +18,20 @@
|
|||||||
import { getAssetThumbnailUrl, handlePromiseError } from '$lib/utils';
|
import { getAssetThumbnailUrl, handlePromiseError } from '$lib/utils';
|
||||||
import { getMapMarkers, type MapMarkerResponseDto } from '@immich/sdk';
|
import { getMapMarkers, type MapMarkerResponseDto } from '@immich/sdk';
|
||||||
import { Icon, modalManager } from '@immich/ui';
|
import { Icon, modalManager } from '@immich/ui';
|
||||||
import mapboxRtlUrl from '@mapbox/mapbox-gl-rtl-text/mapbox-gl-rtl-text.min.js?url';
|
|
||||||
import { mdiCog, mdiMap, mdiMapMarker } from '@mdi/js';
|
import { mdiCog, mdiMap, mdiMapMarker } from '@mdi/js';
|
||||||
import type { Feature, GeoJsonProperties, Geometry, Point } from 'geojson';
|
import type { Feature, GeoJsonProperties, Geometry, Point } from 'geojson';
|
||||||
import { isEqual, omit } from 'lodash-es';
|
import { isEqual, omit } from 'lodash-es';
|
||||||
import { DateTime, Duration } from 'luxon';
|
import { DateTime, Duration } from 'luxon';
|
||||||
import maplibregl, { GlobeControl, type GeoJSONSource, type LngLatLike } from 'maplibre-gl';
|
import {
|
||||||
|
GlobeControl,
|
||||||
|
LngLat,
|
||||||
|
LngLatBounds,
|
||||||
|
Marker,
|
||||||
|
type GeoJSONSource,
|
||||||
|
type LngLatLike,
|
||||||
|
type Map,
|
||||||
|
type MapMouseEvent,
|
||||||
|
} from 'maplibre-gl';
|
||||||
import { onDestroy, onMount, untrack } from 'svelte';
|
import { onDestroy, onMount, untrack } from 'svelte';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import {
|
import {
|
||||||
@ -37,7 +47,6 @@
|
|||||||
NavigationControl,
|
NavigationControl,
|
||||||
Popup,
|
Popup,
|
||||||
ScaleControl,
|
ScaleControl,
|
||||||
type Map,
|
|
||||||
} from 'svelte-maplibre';
|
} from 'svelte-maplibre';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -82,15 +91,15 @@
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bounds = new maplibregl.LngLatBounds();
|
const bounds = new LngLatBounds();
|
||||||
for (const marker of mapMarkers) {
|
for (const marker of mapMarkers) {
|
||||||
bounds.extend([marker.lon, marker.lat]);
|
bounds.extend([marker.lon, marker.lat]);
|
||||||
}
|
}
|
||||||
return bounds;
|
return bounds;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
let map: maplibregl.Map | undefined = $state();
|
let map: Map | undefined = $state();
|
||||||
let marker: maplibregl.Marker | null = null;
|
let marker: Marker | null = null;
|
||||||
let abortController: AbortController;
|
let abortController: AbortController;
|
||||||
|
|
||||||
const theme = $derived($mapSettings.allowDarkMode ? themeManager.value : Theme.LIGHT);
|
const theme = $derived($mapSettings.allowDarkMode ? themeManager.value : Theme.LIGHT);
|
||||||
@ -103,7 +112,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
center = { lng, lat };
|
center = { lng, lat };
|
||||||
marker = new maplibregl.Marker().setLngLat([lng, lat]).addTo(map);
|
marker = new Marker().setLngLat([lng, lat]).addTo(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +134,7 @@
|
|||||||
onSelect(ids);
|
onSelect(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMapClick(event: maplibregl.MapMouseEvent) {
|
function handleMapClick(event: MapMouseEvent) {
|
||||||
if (clickable) {
|
if (clickable) {
|
||||||
const { lng, lat } = event.lngLat;
|
const { lng, lat } = event.lngLat;
|
||||||
onClickPoint({ lng, lat });
|
onClickPoint({ lng, lat });
|
||||||
@ -135,7 +144,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
marker = new maplibregl.Marker().setLngLat([lng, lat]).addTo(map);
|
marker = new Marker().setLngLat([lng, lat]).addTo(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +166,7 @@
|
|||||||
|
|
||||||
const asMarker = (feature: Feature<Geometry, GeoJsonProperties>): MapMarkerResponseDto => {
|
const asMarker = (feature: Feature<Geometry, GeoJsonProperties>): MapMarkerResponseDto => {
|
||||||
const featurePoint = feature as FeaturePoint;
|
const featurePoint = feature as FeaturePoint;
|
||||||
const coords = maplibregl.LngLat.convert(featurePoint.geometry.coordinates as [number, number]);
|
const coords = LngLat.convert(featurePoint.geometry.coordinates as [number, number]);
|
||||||
return {
|
return {
|
||||||
lat: coords.lat,
|
lat: coords.lat,
|
||||||
lon: coords.lng,
|
lon: coords.lng,
|
||||||
@ -294,7 +303,7 @@
|
|||||||
fitBoundsOptions={{ padding: 50, maxZoom: 15 }}
|
fitBoundsOptions={{ padding: 50, maxZoom: 15 }}
|
||||||
attributionControl={false}
|
attributionControl={false}
|
||||||
diffStyleUpdates={true}
|
diffStyleUpdates={true}
|
||||||
onload={(event) => {
|
onload={(event: Map) => {
|
||||||
event.setMaxZoom(18);
|
event.setMaxZoom(18);
|
||||||
event.on('click', handleMapClick);
|
event.on('click', handleMapClick);
|
||||||
if (!simplified) {
|
if (!simplified) {
|
||||||
@ -303,7 +312,7 @@
|
|||||||
}}
|
}}
|
||||||
bind:map
|
bind:map
|
||||||
>
|
>
|
||||||
{#snippet children({ map }: { map: maplibregl.Map })}
|
{#snippet children({ map }: { map: Map })}
|
||||||
{#if showSimpleControls}
|
{#if showSimpleControls}
|
||||||
<NavigationControl position="top-left" showCompass={!simplified} />
|
<NavigationControl position="top-left" showCompass={!simplified} />
|
||||||
|
|
||||||
|
|||||||
@ -169,7 +169,7 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await import('../asset-viewer/asset-viewer.svelte') then { default: AssetViewer }}
|
{#await import('$lib/components/asset-viewer/asset-viewer.svelte') then { default: AssetViewer }}
|
||||||
<AssetViewer
|
<AssetViewer
|
||||||
{withStacked}
|
{withStacked}
|
||||||
asset={$viewingAsset}
|
asset={$viewingAsset}
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
<ModalBody>
|
<ModalBody>
|
||||||
<div class="flex flex-col w-full h-full gap-2 border border-gray-300 dark:border-light rounded-2xl">
|
<div class="flex flex-col w-full h-full gap-2 border border-gray-300 dark:border-light rounded-2xl">
|
||||||
<div class="h-[75vh] min-h-[300px] w-full">
|
<div class="h-[75vh] min-h-[300px] w-full">
|
||||||
{#await import('../components/shared-components/map/map.svelte')}
|
{#await import('$lib/components/shared-components/map/map.svelte')}
|
||||||
{#await delay(timeToLoadTheMap) then}
|
{#await delay(timeToLoadTheMap) then}
|
||||||
<!-- show the loading spinner only if loading the map takes too much time -->
|
<!-- show the loading spinner only if loading the map takes too much time -->
|
||||||
<div class="flex items-center justify-center h-full w-full">
|
<div class="flex items-center justify-center h-full w-full">
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy';
|
|
||||||
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
import Map from '$lib/components/shared-components/map/map.svelte';
|
import { AppRoute, timeToLoadTheMap } from '$lib/constants';
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
import Portal from '$lib/elements/Portal.svelte';
|
import Portal from '$lib/elements/Portal.svelte';
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
import { featureFlags } from '$lib/stores/server-config.store';
|
import { featureFlags } from '$lib/stores/server-config.store';
|
||||||
import { handlePromiseError } from '$lib/utils';
|
import { handlePromiseError } from '$lib/utils';
|
||||||
|
import { delay } from '$lib/utils/asset-utils';
|
||||||
import { navigate } from '$lib/utils/navigation';
|
import { navigate } from '$lib/utils/navigation';
|
||||||
|
import { LoadingSpinner } from '@immich/ui';
|
||||||
import { onDestroy } from 'svelte';
|
import { onDestroy } from 'svelte';
|
||||||
|
import { run } from 'svelte/legacy';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -72,12 +72,21 @@
|
|||||||
{#if $featureFlags.loaded && $featureFlags.map}
|
{#if $featureFlags.loaded && $featureFlags.map}
|
||||||
<UserPageLayout title={data.meta.title}>
|
<UserPageLayout title={data.meta.title}>
|
||||||
<div class="isolate h-full w-full">
|
<div class="isolate h-full w-full">
|
||||||
<Map hash onSelect={onViewAssets} />
|
{#await import('$lib/components/shared-components/map/map.svelte')}
|
||||||
|
{#await delay(timeToLoadTheMap) then}
|
||||||
|
<!-- show the loading spinner only if loading the map takes too much time -->
|
||||||
|
<div class="flex items-center justify-center h-full w-full">
|
||||||
|
<LoadingSpinner />
|
||||||
|
</div>
|
||||||
|
{/await}
|
||||||
|
{:then { default: Map }}
|
||||||
|
<Map hash onSelect={onViewAssets} />
|
||||||
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
</UserPageLayout>
|
</UserPageLayout>
|
||||||
<Portal target="body">
|
<Portal target="body">
|
||||||
{#if $showAssetViewer}
|
{#if $showAssetViewer}
|
||||||
{#await import('../../../../../lib/components/asset-viewer/asset-viewer.svelte') then { default: AssetViewer }}
|
{#await import('$lib/components/asset-viewer/asset-viewer.svelte') then { default: AssetViewer }}
|
||||||
<AssetViewer
|
<AssetViewer
|
||||||
asset={$viewingAsset}
|
asset={$viewingAsset}
|
||||||
showNavigation={viewingAssets.length > 1}
|
showNavigation={viewingAssets.length > 1}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user