mirror of
https://github.com/immich-app/immich.git
synced 2025-06-03 13:44:16 -04:00
refactor: shared link url (#18185)
This commit is contained in:
parent
ff63b0fa8f
commit
55af925ab3
@ -23,7 +23,6 @@
|
|||||||
locale,
|
locale,
|
||||||
type AlbumViewSettings,
|
type AlbumViewSettings,
|
||||||
} from '$lib/stores/preferences.store';
|
} from '$lib/stores/preferences.store';
|
||||||
import { serverConfig } from '$lib/stores/server-config.store';
|
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
import { userInteraction } from '$lib/stores/user.svelte';
|
import { userInteraction } from '$lib/stores/user.svelte';
|
||||||
import { makeSharedLinkUrl } from '$lib/utils';
|
import { makeSharedLinkUrl } from '$lib/utils';
|
||||||
@ -367,9 +366,8 @@
|
|||||||
const sharedLink = await modalManager.show(SharedLinkCreateModal, { albumId: albumToShare.id });
|
const sharedLink = await modalManager.show(SharedLinkCreateModal, { albumId: albumToShare.id });
|
||||||
|
|
||||||
if (sharedLink) {
|
if (sharedLink) {
|
||||||
const url = makeSharedLinkUrl($serverConfig.externalDomain, sharedLink.key);
|
|
||||||
handleSharedLinkCreated(albumToShare);
|
handleSharedLinkCreated(albumToShare);
|
||||||
await modalManager.show(QrCodeModal, { title: $t('view_link'), value: url });
|
await modalManager.show(QrCodeModal, { title: $t('view_link'), value: makeSharedLinkUrl(sharedLink.key) });
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
import { modalManager } from '$lib/managers/modal-manager.svelte';
|
import { modalManager } from '$lib/managers/modal-manager.svelte';
|
||||||
import QrCodeModal from '$lib/modals/QrCodeModal.svelte';
|
import QrCodeModal from '$lib/modals/QrCodeModal.svelte';
|
||||||
import SharedLinkCreateModal from '$lib/modals/SharedLinkCreateModal.svelte';
|
import SharedLinkCreateModal from '$lib/modals/SharedLinkCreateModal.svelte';
|
||||||
import { serverConfig } from '$lib/stores/server-config.store';
|
|
||||||
import { makeSharedLinkUrl } from '$lib/utils';
|
import { makeSharedLinkUrl } from '$lib/utils';
|
||||||
import type { AssetResponseDto } from '@immich/sdk';
|
import type { AssetResponseDto } from '@immich/sdk';
|
||||||
import { mdiShareVariantOutline } from '@mdi/js';
|
import { mdiShareVariantOutline } from '@mdi/js';
|
||||||
@ -19,8 +18,7 @@
|
|||||||
const sharedLink = await modalManager.show(SharedLinkCreateModal, { assetIds: [asset.id] });
|
const sharedLink = await modalManager.show(SharedLinkCreateModal, { assetIds: [asset.id] });
|
||||||
|
|
||||||
if (sharedLink) {
|
if (sharedLink) {
|
||||||
const url = makeSharedLinkUrl($serverConfig.externalDomain, sharedLink.key);
|
await modalManager.show(QrCodeModal, { title: $t('view_link'), value: makeSharedLinkUrl(sharedLink.key) });
|
||||||
await modalManager.show(QrCodeModal, { title: $t('view_link'), value: url });
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
import { modalManager } from '$lib/managers/modal-manager.svelte';
|
import { modalManager } from '$lib/managers/modal-manager.svelte';
|
||||||
import QrCodeModal from '$lib/modals/QrCodeModal.svelte';
|
import QrCodeModal from '$lib/modals/QrCodeModal.svelte';
|
||||||
import SharedLinkCreateModal from '$lib/modals/SharedLinkCreateModal.svelte';
|
import SharedLinkCreateModal from '$lib/modals/SharedLinkCreateModal.svelte';
|
||||||
import { serverConfig } from '$lib/stores/server-config.store';
|
|
||||||
import { makeSharedLinkUrl } from '$lib/utils';
|
import { makeSharedLinkUrl } from '$lib/utils';
|
||||||
import { mdiShareVariantOutline } from '@mdi/js';
|
import { mdiShareVariantOutline } from '@mdi/js';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
@ -17,8 +16,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (sharedLink) {
|
if (sharedLink) {
|
||||||
const url = makeSharedLinkUrl($serverConfig.externalDomain, sharedLink.key);
|
await modalManager.show(QrCodeModal, { title: $t('view_link'), value: makeSharedLinkUrl(sharedLink.key) });
|
||||||
await modalManager.show(QrCodeModal, { title: $t('view_link'), value: url });
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||||
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
||||||
import { serverConfig } from '$lib/stores/server-config.store';
|
|
||||||
import { copyToClipboard, makeSharedLinkUrl } from '$lib/utils';
|
import { copyToClipboard, makeSharedLinkUrl } from '$lib/utils';
|
||||||
import type { SharedLinkResponseDto } from '@immich/sdk';
|
import type { SharedLinkResponseDto } from '@immich/sdk';
|
||||||
import { mdiContentCopy } from '@mdi/js';
|
import { mdiContentCopy } from '@mdi/js';
|
||||||
@ -15,7 +14,7 @@
|
|||||||
let { link, menuItem = false }: Props = $props();
|
let { link, menuItem = false }: Props = $props();
|
||||||
|
|
||||||
const handleCopy = async () => {
|
const handleCopy = async () => {
|
||||||
await copyToClipboard(makeSharedLinkUrl($serverConfig.externalDomain, link.key));
|
await copyToClipboard(makeSharedLinkUrl(link.key));
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
|
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import QrCodeModal from '$lib/modals/QrCodeModal.svelte';
|
import QrCodeModal from '$lib/modals/QrCodeModal.svelte';
|
||||||
import { serverConfig } from '$lib/stores/server-config.store';
|
|
||||||
import { makeSharedLinkUrl } from '$lib/utils';
|
import { makeSharedLinkUrl } from '$lib/utils';
|
||||||
import {
|
import {
|
||||||
AlbumUserRole,
|
AlbumUserRole,
|
||||||
@ -34,7 +33,7 @@
|
|||||||
|
|
||||||
let sharedLinkUrl = $state('');
|
let sharedLinkUrl = $state('');
|
||||||
const handleViewQrCode = (sharedLink: SharedLinkResponseDto) => {
|
const handleViewQrCode = (sharedLink: SharedLinkResponseDto) => {
|
||||||
sharedLinkUrl = makeSharedLinkUrl($serverConfig.externalDomain, sharedLink.key);
|
sharedLinkUrl = makeSharedLinkUrl(sharedLink.key);
|
||||||
};
|
};
|
||||||
|
|
||||||
const roleOptions: Array<{ title: string; value: AlbumUserRole | 'none'; icon?: string }> = [
|
const roleOptions: Array<{ title: string; value: AlbumUserRole | 'none'; icon?: string }> = [
|
||||||
|
@ -2,6 +2,7 @@ import { NotificationType, notificationController } from '$lib/components/shared
|
|||||||
import { defaultLang, langs, locales } from '$lib/constants';
|
import { defaultLang, langs, locales } from '$lib/constants';
|
||||||
import { authManager } from '$lib/managers/auth-manager.svelte';
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
||||||
import { lang } from '$lib/stores/preferences.store';
|
import { lang } from '$lib/stores/preferences.store';
|
||||||
|
import { serverConfig } from '$lib/stores/server-config.store';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
import {
|
import {
|
||||||
AssetJobName,
|
AssetJobName,
|
||||||
@ -256,8 +257,8 @@ export const copyToClipboard = async (secret: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const makeSharedLinkUrl = (externalDomain: string, key: string) => {
|
export const makeSharedLinkUrl = (key: string) => {
|
||||||
return new URL(`share/${key}`, externalDomain || globalThis.location.origin).href;
|
return new URL(`share/${key}`, get(serverConfig).externalDomain || globalThis.location.origin).href;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const oauth = {
|
export const oauth = {
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
import { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
import { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
import { AssetStore } from '$lib/stores/assets-store.svelte';
|
import { AssetStore } from '$lib/stores/assets-store.svelte';
|
||||||
import { serverConfig } from '$lib/stores/server-config.store';
|
|
||||||
import { SlideshowNavigation, SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
import { SlideshowNavigation, SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
||||||
import { preferences, user } from '$lib/stores/user.store';
|
import { preferences, user } from '$lib/stores/user.store';
|
||||||
import { handlePromiseError, makeSharedLinkUrl } from '$lib/utils';
|
import { handlePromiseError, makeSharedLinkUrl } from '$lib/utils';
|
||||||
@ -439,8 +438,7 @@
|
|||||||
const sharedLink = await modalManager.show(SharedLinkCreateModal, { albumId: album.id });
|
const sharedLink = await modalManager.show(SharedLinkCreateModal, { albumId: album.id });
|
||||||
|
|
||||||
if (sharedLink) {
|
if (sharedLink) {
|
||||||
const url = makeSharedLinkUrl($serverConfig.externalDomain, sharedLink.key);
|
await modalManager.show(QrCodeModal, { title: $t('view_link'), value: makeSharedLinkUrl(sharedLink.key) });
|
||||||
await modalManager.show(QrCodeModal, { title: $t('view_link'), value: url });
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user