Compare commits

...

7 Commits

Author SHA1 Message Date
Alex
880ff7af5e Merge branch 'main' into fix/shared-link-nav 2026-04-24 10:20:43 -05:00
Mees Frensel
57e1b172dd dont use onMount 2026-04-22 12:59:29 +02:00
Mees Frensel
7efafd9db1 chore: use special case for shared link with slug route 2026-04-21 12:54:54 +02:00
Mees Frensel
f597ebb672 use regex after all 2026-04-16 13:30:04 +02:00
Mees Frensel
b9694d9b52 Merge branch 'main' into fix/shared-link-nav 2026-04-16 11:48:25 +02:00
Mees Frensel
925fabff27 Merge branch 'main' into fix/shared-link-nav 2026-04-14 15:25:56 +02:00
Mees Frensel
33ec6ee0e8 fix(web): fix shared link navigation after password login 2026-04-14 15:17:38 +02:00
2 changed files with 22 additions and 17 deletions

View File

@@ -36,6 +36,10 @@
let isOwned = $derived(authManager.authenticated && authManager.user.id === sharedLink?.userId);
let password = $state('');
if (passwordRequired) {
assetViewerManager.showAssetViewer(false);
}
const handlePasswordSubmit = async () => {
try {
sharedLink = await sharedLinkLogin({ key, slug, sharedLinkLoginDto: { password } });
@@ -101,10 +105,10 @@
</header>
{/if}
{#if !passwordRequired && sharedLink?.type == SharedLinkType.Album}
{#if !passwordRequired && sharedLink?.type === SharedLinkType.Album}
<AlbumViewer {sharedLink} />
{/if}
{#if !passwordRequired && sharedLink?.type == SharedLinkType.Individual}
{#if !passwordRequired && sharedLink?.type === SharedLinkType.Individual}
<div class="immich-scrollbar">
<IndividualSharedViewer {sharedLink} {isOwned} />
</div>

View File

@@ -1,6 +1,6 @@
import { get } from 'svelte/store';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { page } from '$app/state';
import type { RouteId } from '$app/types';
import { assetCacheManager } from '$lib/managers/AssetCacheManager.svelte';
import { Route } from '$lib/route';
@@ -13,8 +13,9 @@ export const isExternalUrl = (url: string): boolean => {
};
export const isPhotosRoute = (route?: string | null) => !!route?.startsWith('/(user)/photos/[[assetId=id]]');
const isSharedLinkSlugRoute = (route?: string | null) => !!route?.startsWith('/(user)/s/[slug]');
export const isSharedLinkRoute = (route?: string | null) =>
!!route?.startsWith('/(user)/share/[key]') || !!route?.startsWith('/(user)/s/[slug]');
!!route?.startsWith('/(user)/share/[key]') || isSharedLinkSlugRoute(route);
export const isSearchRoute = (route?: string | null) => !!route?.startsWith('/(user)/search');
export const isAlbumsRoute = (route?: string | null) => !!route?.startsWith('/(user)/albums/[albumId=id]');
export const isPeopleRoute = (route?: string | null) => !!route?.startsWith('/(user)/people/[personId]');
@@ -29,31 +30,32 @@ export function getAssetInfoFromParam({ assetId, slug, key }: { assetId?: string
}
function currentUrlWithoutAsset() {
const $page = get(page);
// This contains special casing for the /photos/:assetId route, which hangs directly
// off / instead of a subpath, unlike every other asset-containing route.
return isPhotosRoute($page.route.id)
? Route.photos() + $page.url.search
: $page.url.pathname.replace(/(\/photos.*)$/, '') + $page.url.search;
if (isPhotosRoute(page.route.id)) {
return Route.photos() + page.url.search;
} else if (isSharedLinkSlugRoute(page.route.id)) {
return Route.viewSharedLink({ slug: page.data.slug, key: page.data.key }) + page.url.search;
} else {
return page.url.pathname.replace(/(\/photos.*)$/, '') + page.url.search;
}
}
export function currentUrlReplaceAssetId(assetId: string) {
const $page = get(page);
const params = new URLSearchParams($page.url.search);
const params = new URLSearchParams(page.url.search);
// always remove the assetGridScrollTargetParams
params.delete('at');
const paramsString = params.toString();
const searchparams = paramsString == '' ? '' : '?' + params.toString();
// this contains special casing for the /photos/:assetId photos route, which hangs directly
// off / instead of a subpath, unlike every other asset-containing route.
return isPhotosRoute($page.route.id)
return isPhotosRoute(page.route.id)
? `${Route.viewAsset({ id: assetId })}${searchparams}`
: `${$page.url.pathname.replace(/\/photos\/[^/]+$/, '')}/photos/${assetId}${searchparams}`;
: `${page.url.pathname.replace(/\/photos\/[^/]+$/, '')}/photos/${assetId}${searchparams}`;
}
function replaceScrollTarget(url: string, searchParams?: AssetGridRouteSearchParams | null) {
const $page = get(page);
const parsed = new URL(url, $page.url);
const parsed = new URL(url, page.url);
const { at: assetId } = searchParams || { at: null };
@@ -61,7 +63,7 @@ function replaceScrollTarget(url: string, searchParams?: AssetGridRouteSearchPar
return parsed.pathname;
}
const params = new URLSearchParams($page.url.search);
const params = new URLSearchParams(page.url.search);
if (assetId) {
params.set('at', assetId);
}
@@ -69,8 +71,7 @@ function replaceScrollTarget(url: string, searchParams?: AssetGridRouteSearchPar
}
function currentUrl() {
const $page = get(page);
const current = $page.url;
const current = page.url;
return current.pathname + current.search + current.hash;
}