Skip to content

High performance self-hosted photo and video management solution.

fix: only load rtl plugin once (#12365)

Jason Rasmussend6729c50c983
diff --git a/web/src/lib/components/shared-components/map/map.svelte b/web/src/lib/components/shared-components/map/map.svelte
index 7d0dbbee6f..d769d8a559 100644
--- a/web/src/lib/components/shared-components/map/map.svelte
+++ b/web/src/lib/components/shared-components/map/map.svelte
@@ -1,15 +1,20 @@
+<script lang="ts" context="module">
+ void maplibregl.setRTLTextPlugin(mapboxRtlUrl, true);
+</script>
+
<script lang="ts">
import Icon from '$lib/components/elements/icon.svelte';
import { Theme } from '$lib/constants';
import { colorTheme, mapSettings } from '$lib/stores/preferences.store';
import { getAssetThumbnailUrl, getKey, handlePromiseError } from '$lib/utils';
import { getMapStyle, MapTheme, type MapMarkerResponseDto } from '@immich/sdk';
+ import mapboxRtlUrl from '@mapbox/mapbox-gl-rtl-text/mapbox-gl-rtl-text.min.js?url';
import { mdiCog, mdiMap, mdiMapMarker } from '@mdi/js';
import type { Feature, GeoJsonProperties, Geometry, Point } from 'geojson';
import type { GeoJSONSource, LngLatLike, StyleSpecification } from 'maplibre-gl';
- import mapboxRtlUrl from '@mapbox/mapbox-gl-rtl-text/mapbox-gl-rtl-text.min.js?url';
import maplibregl from 'maplibre-gl';
import { createEventDispatcher } from 'svelte';
+ import { t } from 'svelte-i18n';
import {
AttributionControl,
Control,
@@ -25,7 +30,6 @@
ScaleControl,
type Map,
} from 'svelte-maplibre';
- import { t } from 'svelte-i18n';
export let mapMarkers: MapMarkerResponseDto[];
export let showSettingsModal: boolean | undefined = undefined;
@@ -52,8 +56,6 @@
let map: maplibregl.Map;
let marker: maplibregl.Marker | null = null;
- void maplibregl.setRTLTextPlugin(mapboxRtlUrl, true);
-
$: style = (() =>
getMapStyle({
theme: ($mapSettings.allowDarkMode ? $colorTheme.value : Theme.LIGHT) as unknown as MapTheme,
diff --git a/web/src/lib/utils/server.ts b/web/src/lib/utils/server.ts
index d2c5ab1851..1c52274d23 100644
--- a/web/src/lib/utils/server.ts
+++ b/web/src/lib/utils/server.ts
@@ -3,17 +3,13 @@ import { initLanguage } from '$lib/utils';
import { defaults } from '@immich/sdk';
import { memoize } from 'lodash-es';
-type fetchType = typeof fetch;
+type Fetch = typeof fetch;
-export function initSDK(fetch: fetchType) {
+async function _init(fetch: Fetch) {
// set event.fetch on the fetch-client used by @immich/sdk
// https://kit.svelte.dev/docs/load#making-fetch-requests
// https://github.com/oazapfts/oazapfts/blob/main/README.md#fetch-options
defaults.fetch = fetch;
-}
-
-async function _init(fetch: fetchType) {
- initSDK(fetch);
await initLanguage();
await retrieveServerConfig();
}