diff --git a/web/src/lib/components/asset-viewer/detail-panel-location.svelte b/web/src/lib/components/asset-viewer/detail-panel-location.svelte index 1a3779f528..15ea4d94ca 100644 --- a/web/src/lib/components/asset-viewer/detail-panel-location.svelte +++ b/web/src/lib/components/asset-viewer/detail-panel-location.svelte @@ -1,24 +1,20 @@ {#if menuItem} - (isShowChangeLocation = true)} - /> -{/if} -{#if isShowChangeLocation} - + {/if} diff --git a/web/src/lib/index.spec.ts b/web/src/lib/index.spec.ts index bda5a9e722..20f1244d50 100644 --- a/web/src/lib/index.spec.ts +++ b/web/src/lib/index.spec.ts @@ -1,4 +1,4 @@ -import { cleanClass } from '$lib'; +import { cleanClass, isDefined } from '$lib'; describe('cleanClass', () => { it('should return a string of class names', () => { @@ -13,3 +13,19 @@ describe('cleanClass', () => { expect(cleanClass('class1', ['class2', 'class3'])).toBe('class1 class2 class3'); }); }); + +describe('isDefined', () => { + it('should return false for null', () => { + expect(isDefined(null)).toBe(false); + }); + + it('should return false for undefined', () => { + expect(isDefined(undefined)).toBe(false); + }); + + it('should return true for everything else', () => { + for (const value of [0, 1, 2, true, false, {}, 'foo', 'bar', []]) { + expect(isDefined(value)).toBe(true); + } + }); +}); diff --git a/web/src/lib/index.ts b/web/src/lib/index.ts index b4fc195626..e659dadd46 100644 --- a/web/src/lib/index.ts +++ b/web/src/lib/index.ts @@ -14,3 +14,5 @@ export const cleanClass = (...classNames: unknown[]) => { .join(' '), ); }; + +export const isDefined = (value: T): value is NonNullable => value !== null && value !== undefined; diff --git a/web/src/lib/managers/geolocation.manager.svelte.ts b/web/src/lib/managers/geolocation.manager.svelte.ts new file mode 100644 index 0000000000..d5b2c43912 --- /dev/null +++ b/web/src/lib/managers/geolocation.manager.svelte.ts @@ -0,0 +1,15 @@ +import type { LatLng } from '$lib/types'; + +class GeolocationManager { + #lastPoint = $state(); + + get lastPoint() { + return this.#lastPoint; + } + + onSelected(point: LatLng) { + this.#lastPoint = point; + } +} + +export const geolocationManager = new GeolocationManager(); diff --git a/web/src/lib/components/shared-components/change-location.svelte b/web/src/lib/modals/GeolocationPointPickerModal.svelte similarity index 85% rename from web/src/lib/components/shared-components/change-location.svelte rename to web/src/lib/modals/GeolocationPointPickerModal.svelte index 1abb2dacce..87b1df081a 100644 --- a/web/src/lib/components/shared-components/change-location.svelte +++ b/web/src/lib/modals/GeolocationPointPickerModal.svelte @@ -1,30 +1,27 @@ {#snippet prompt()}

{$t('update_location_action_prompt', { values: { count: assetCount } })}

-

- {$t('latitude')}: {location.latitude}

-

- {$t('longitude')}: {location.longitude}

+

- {$t('latitude')}: {point.lat}

+

- {$t('longitude')}: {point.lng}

{/snippet}
diff --git a/web/src/lib/stores/asset-editor.store.ts b/web/src/lib/stores/asset-editor.store.ts deleted file mode 100644 index cc764cf7ad..0000000000 --- a/web/src/lib/stores/asset-editor.store.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { writable } from 'svelte/store'; - -//-----other -export const lastChosenLocation = writable<{ lng: number; lat: number } | null>(null); diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts index 25524f1eea..619195711a 100644 --- a/web/src/lib/types.ts +++ b/web/src/lib/types.ts @@ -5,6 +5,8 @@ import type { ActionItem } from '@immich/ui'; import type { DateTime } from 'luxon'; import type { SvelteSet } from 'svelte/reactivity'; +export type LatLng = { lng: number; lat: number }; + export interface ReleaseEvent { isAvailable: boolean; /** ISO8601 */ diff --git a/web/src/routes/(user)/utilities/geolocation/+page.svelte b/web/src/routes/(user)/utilities/geolocation/+page.svelte index 9c8ad035f4..d8cd0c3850 100644 --- a/web/src/routes/(user)/utilities/geolocation/+page.svelte +++ b/web/src/routes/(user)/utilities/geolocation/+page.svelte @@ -1,6 +1,6 @@